Reputation: 19
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!
Upvotes: 1
Views: 644
Reputation: 2956
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
);
Upvotes: 2