Pespective device camera access, how to access?

Good day! How do you access the devices’ camera through the perspective page?

What are you trying to accomplish?

Access to the camera is limited to use cases like barcode scanning and only available when running one of the Perspective mobile apps.

i want to scan barcodes, like you suggest.

It looks like you use the Barcode Scanned session event along with the Scan Barcode action.

Thanks Kevin, all that was really useful. I am also interested in being able to scan a QR code that houses a URL. Can I navigate to that URL from here?

Yes, in the barcode scanned event you can just invoke system.perspective.navigate:
https://docs.inductiveautomation.com/display/DOC81/system.perspective.navigate

Thanks PGriffith, when I use the script

system.perspective.navigate(url = 'self.getSibling("Label").props.text')

which is this url, -https://inductiveautomation.com/ignition/maker-edition-, it says “view not found”, do I need to have a web browser module for perspective? *i had to put the - before and after the url here so it wouldnt create shortcut link

Don’t wrap it in quotes.
system.perspective.navigate(url = 'self.getSibling("Label").props.text')
Means "send me to the url 'self.getSibling("Label").props.text'".

system.perspective.navigate(url = self.getSibling("Label").props.text)
Means "send me to the url with a text value specified by self.getSibling("Label").props.text".

when I do

system.perspective.navigate(url = self.getSibling("Label").props.text)

I dont navigate anywhere

Where are you actually putting this script? Are there any errors in the gateway or browser logs?

Here is a pic of where im putting this script:

the error i get:

This code is in a session event, and doesn’t have a self argument defined. The self.getSibling() is intended to be called from another component on the same view as Label.

I see what you mean, I changed it to this now:

	system.tag.writeAsync(['[default]Barcode Data'], [data.text])
	system.perspective.navigate(url = '[default]Barcode Data')

I had to leave the ’ ’ on the script or it would say the syntax was wrong, like this:

this is the error i get now:

I think you’re looking for this:

system.tag.writeAsync(['[default]Barcode Data'], [data])
system.perspective.navigate(url = data)

assuming that data is a valid URL. Also, not sure if writeAsync is really what you want, but it’s not hurting anything. Also, I’m not sure you can use navigate from this place.

1 Like

Instead of writing to a tag, you should be sending this through ad the context if that is coming from a label on the page. Unless of course the label text is bound to the barcode scan data?

I am unsure:

I could not navigate from there. Not sure why but to get it to navigate, I added an extra button with the navigate script on it bindsed back to the prop.text of the label that the barcode scanned wrote to. For me, it works fine.

Thanks alot everyone.