I am using PhoneGap Build to wrap an AngularJS project as a mobile app, it uses InAppBrowser to open Facebook/Twitter OAuth page.
My configuration:
Here is the code snippet I used:
// This part code is called from click handler of a button,
// this is the only place that used the PhoneGap API.
var ipwin; // Used in somewhere else
document.addEventListener("deviceready", function() {
ipwin = $window.open("some url", "_blank");
$(ipwin).on("loadstop", function(e) {
var url = e.originalEvent.url;
console.log("loadstop: " + url);
// snipped
});
// Below are testing code added while debugging
var test = function() {
console.log("setTimeout test");
};
setTimeout(test, 2000);
test();
}, false);
This works fine on Android 4.0, however on Android 2.3 the loadstop
event does not fire. I also tried loadstart
and loaderror
, none of them fires. More strangely, setTimeout test
only appears in console output once instead of twice. Is there any problem in my code?
After some refactor and changes to the app, the problem is mysteriously gone. Not entirely sure but I think it is because some other scripts in the page conflicted with cordova.js.