简体   繁体   中英

notification.confirm callback not firing phonegap iOS

I'm using Phonegap (Cordova) v1.9, and this app is solely for iPhone4+ use.

I've tried the two methods below, on their own and simultaneously.

Phonegap's deviceready event has been fired previous to this code.

I'm using the iPhone configuration utility to watch the console, but I'm not getting anything from the code below.

Also, I'm using Sencha Touch (v1.1) and jQuery. No conflicts noticed throughout the app.

Please help?

function onConfirmCallback(button){
    console.log("onConfirmCallback");
    console.log(button);
}

var toConfirm = navigator.notification.confirm("You don't have a pincode set.\nWould you like to set one now?", onConfirmCallback, "Pincode", "Yes,No");
toConfirm.onAlertDismissed = function(index, label){
    console.log("onAlertDismissed");
    console.log(index);
}

Have you tried looking for exceptions to see what might be happening?

try
{
    var toConfirm = navigator.notification.confirm("You don't have a pincode set.\nWould you like to set one now?", onConfirmCallback, "Pincode", "Yes,No");
    toConfirm.onAlertDismissed = function(index, label) {
        console.log("onAlertDismissed");
        console.log(index);
    }
}
catch (ex)
{
    console.log(ex.message);
}

Edit:

The example mentioned in the comment below (from https://groups.google.com/group/phonegap/browse_thread/thread/126f56f4e296e555 ) is for PhoneGap 0.9.2. I have not seen any examples for v1.3 where the confirm function returns an object as your using with 'toConfirm'. Maybe that is causing your problem. Have you tried the following (removing all other code to do with toConfirm to simplify the problem)?

navigator.notification.confirm("You don't have a pincode set.\nWould you like to set one now?", onConfirmCallback, "Pincode", "Yes,No");

http://docs.phonegap.com/en/1.3.0/phonegap_notification_notification.md.html#notification.confirm

Also, is there any reason your not using a newer version of PhoneGap (Cordova)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM