質問

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:

  • Angular 1.0.8
  • PhoneGap 3.1.0 on PhoneGap Build
  • InAppBrowser 0.2.3
  • Tested with hydration enabled and disabled, same result

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.

他のヒント

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.

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.

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top