Page 1 of 2

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

Posted: Tue Oct 08, 2013 9:21 am
by 3uriah

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


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

Posted: Tue Oct 08, 2013 10:05 am
by Maryna Brodina

Hello! Working on it. I'll update.


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

Posted: Tue Oct 08, 2013 10:13 am
by 3uriah

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


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

Posted: Tue Oct 08, 2013 11:16 am
by Maryna Brodina

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...


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

Posted: Tue Oct 08, 2013 12:13 pm
by 3uriah

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.


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

Posted: Tue Oct 08, 2013 1:28 pm
by Maryna Brodina

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.


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

Posted: Tue Oct 08, 2013 3:31 pm
by 3uriah

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?


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

Posted: Tue Oct 08, 2013 8:53 pm
by Kateryna Grynko

Hi,

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


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

Posted: Wed Oct 09, 2013 12:39 am
by 3uriah

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?


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

Posted: Wed Oct 09, 2013 9:32 am
by Maryna Brodina

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.