1

When I use this code:

function dialogConfirm() {
    var message = "Am I Confirm Dialog?";
    var title = "CONFIRM";
    var buttonLabels = "YES,NO";
    navigator.notification.confirm(message, confirmCallback, title, buttonLabels);

function confirmCallback(buttonIndex) {
    navigator.notification.alert("You clicked " + buttonIndex + " button!",null,"helo","Nic");
}

 }

However on android when I deploy with Cordova and I click on one of the btns of confirm the alert does not popUp so I tried with some text and I found out that the function confirmCallBack is never called whatever btn I click so does anyone know what can I do to call the confirmCallBack function or is it just a bug with the plugin in android. I remind you that on Windows Browser it works perfectly so the issue is either with the library or with my device it is a Moto G 3rd Generation android 7.0.1 Thanks in advance!

7
  • have you tried the confirm* without **title, buttonLabels navigator.notification.confirm('Delete?', function() { alert("Hi"); }); Commented Jul 5, 2018 at 10:18
  • works just fine for me on android devices. Maybe you can try to update the notification plugin?
    – QuickFix
    Commented Jul 5, 2018 at 10:33
  • @NullPointer yes the call works perfectly the issue is that on my phone it does not start the function when I click "Yes" e.x
    – Nic_D0t
    Commented Jul 5, 2018 at 11:09
  • @QuickFix I will give it a try
    – Nic_D0t
    Commented Jul 5, 2018 at 11:09
  • Did not work! Anything new?
    – Nic_D0t
    Commented Jul 5, 2018 at 12:19

1 Answer 1

2

Your options buttons are a string instead of an array.

message: Dialog message. (String)

confirmCallback: Callback to invoke with index of button pressed (1, 2, or 3) or when the dialog is dismissed without a button press (0). (Function)

title: Dialog title. (String) (Optional, defaults to Confirm)

buttonLabels: Array of strings specifying button labels. (Array) (Optional, defaults to [OK,Cancel])

Try this sample from the original Dialogs plugin documentation:

function onConfirm(buttonIndex) {
    console.log('You selected button ' + buttonIndex);
    navigator.notification.alert('You selected button ' + buttonIndex);
}

navigator.notification.confirm(
    'You are the winner!', // message
     onConfirm,            // callback to invoke with index of button pressed
    'Game Over',           // title
    ['Restart','Exit']     // buttonLabels
);

Not the answer you're looking for? Browse other questions tagged or ask your own question.