3uriah
Posts: 0
Joined: Tue Oct 08, 2013 9:21 am

Barcode Scanner: How to open up url upon scan completion.

Greetings,

I'm building a barcode scanner that aims to scan QR Codes. Upon completion of the scan, I want the url to be opened up in a browser. Is there way to do this? So far I've only managed to return the url into the link component, which requires me to click the link to launch the url.

Thanks

Image

Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Barcode Scanner: How to open up url upon scan completion.

Hello! Working on it. I'll update.

3uriah
Posts: 0
Joined: Tue Oct 08, 2013 9:21 am

Barcode Scanner: How to open up url upon scan completion.

Thank you for the very fast response! Looking forward to your updates!

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Barcode Scanner: How to open up url upon scan completion.

On service Success you can add the code to navigate to link. You can open link in childBrowser or in default device browser. This should help https://getsatisfaction.com/apperyio/...
http://cordova.apache.org/docs/en/2.9...

3uriah
Posts: 0
Joined: Tue Oct 08, 2013 9:21 am

Barcode Scanner: How to open up url upon scan completion.

if I follow:

  1. Component: mobilebarcode1

  2. Event: Success

  3. Action: Navigate to Link

    this results in having to input a static url. Rather, what I want to know is what code do I use to:

  4. Acquire the url acquired from a QR code via the barcode scanner

  5. Open that url in the default device browser.

    In short, I want to scan a QR code and on success, automatically have the browser open that url.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Barcode Scanner: How to open up url upon scan completion.

On service success add Run JavaScript action with the following code:
prewindow.open(data.text, '_system', 'location=yes');/pre
Before that code you can also add code to check if data.text is a valid URL, if not - then do not navigate there.

3uriah
Posts: 0
Joined: Tue Oct 08, 2013 9:21 am

Barcode Scanner: How to open up url upon scan completion.

Hi Marina,

I take it data.text is meant to grab whatever text is pulled form the QR Code, i.e. http://www.google.com. such that when window.open is used it results in,

window.open(http://www.google.com, '_system', 'location=yes');

which should cause a browser to open up and navigate me to google.com

however upon scan completion the browser isn't being opened :/ did I need some extra coding somewhere? Or binding the barcode component to something extra?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Barcode Scanner: How to open up url upon scan completion.

Hi,

You should wrap link in quotes:
codewindow.open("http://www.google.com", "_system", "location=yes");/code

3uriah
Posts: 0
Joined: Tue Oct 08, 2013 9:21 am

Barcode Scanner: How to open up url upon scan completion.

Hi Katya,

Sorry, what I mean is that if the barcode scanner scans a QR code that has the text (or rather the url) http://www.google.com or http://appery.io, I want it to substitute into:

window.open('PLACE TEXT FROM QR CODE HERE", "_system", "location=yes")

I think the code Marina gave me should work,

window.open(data.text, '_system', 'location=yes');

but i'm thinking I'm missing some steps, such as data.text might not have any information from the barcode stored in it?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Barcode Scanner: How to open up url upon scan completion.

Hello! Did you add this code on on barcode scanner service success event?
prewindow.open(data.text, '_system', 'location=yes');/pre
You don't need to change anything, just add this code.

Return to “Issues”