SAPikachu
SAPikachu

Reputation: 619

InAppBrowser (PhoneGap Build 3.1.0) events do not fire on Android 2.3

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?

Upvotes: 1

Views: 2123

Answers (4)

Matty J
Matty J

Reputation: 3156

I was experiencing similar problems with both PhoneGap 3.0 and 3.1 on Android, reverting to PhoneGap 2.9 made these InAppBrowser events fire again.

Upvotes: 1

SAPikachu
SAPikachu

Reputation: 619

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.

Upvotes: 1

Hazem Hagrass
Hazem Hagrass

Reputation: 9848

this issue happened to me and I did these steps to solve it:

  • Upgrade your Phonegap version to 3.1
  • Create a new project
  • Add your platforms then your plugins
  • Copy your code again back to www

this should solve your problem

Upvotes: 0

Nereis
Nereis

Reputation: 576

It looks like to be a problem with the last phonegap/cordova version 3.1.0.

https://groups.google.com/forum/#!topic/phonegap/e5_5unC2fYs

Try an older version.

Upvotes: 0

Related Questions