purplecabbage/phonegap-plugins — Issue #66: Childbrowser doesn't open from Barcodescanner in iOS
Author: KickstandGroup
Created: 2012-02-26 05:19:56+00:00
State: open

My first post ever, so sorry for the ignorance, and any feedback is hugely appreciated. i admit I'm a bit if a hack - haven't touched C in 25 years and this is my first web app.

I have both the scanner working and childbrowser working in the app. I can scan a QR code and open in Safari just fine, but can't scan into a childbrowser view. I get no errors at all in the device console - the window just doesn't open and the view returns to the page where the scan is launched. The function's shown below, and i also found a method of changing the native code to load all links in the childbrowser (which works great - but same problem --doesn't work with barcodescanner).

Been beating my head against a wall on this for nights now - thanks in advance!!!!

//------------------------------------------------------------------------------
var button
var result
var childBrowser

//------------------------------------------------------------------------------
function onLoad() {
if (!window.PhoneGap) {
alert("PhoneGap is not available")
return
}

document.addEventListener("deviceready",onDeviceReady,false)

button = document.getElementById("scan-button")
resultSpan = document.getElementById("scan-result")

}

//------------------------------------------------------------------------------
function onDeviceReady() {
button.addEventListener("click", onClick, false)
document.addEventListener("offline", onOffline, false)
childBrowser = ChildBrowser.install();
}

//------------------------------------------------------------------------------
function onClick() {
window.plugins.barcodeScanner.scan(scannerSuccess, scannerFailure)
}

//------------------------------------------------------------------------------
function scannerSuccess(result) {
console.log("scannerSuccess: result: " + JSON.stringify(result.text));
resultSpan.innerText = (result.text);
if (result.cancelled)
window.location.replace("index.html")
else
window.plugins.childBrowser.showWebPage(result.text)
}

//------------------------------------------------------------------------------
function scannerFailure(message) {
console.log("scannerFailure: message: " + JSON.stringify(message))
}