Reputation: 6551
I am doing a phonegap project for iphone, i have a phonegap alert inside a confirmation notification callback. My confirmation (navigator.notification.confirm)
works fine but alert(navigator.notification.alert)
not working, don't know why is it so, pasted my code below.
function confirmSubmit() {
navigator.notification.confirm(
'Are you ready to submit?', // message
function(buttonIndex) {
onConfirm(buttonIndex);
},
'Confirmation', 'Yes,No' // buttonLabels
);
}
function onConfirm(buttonIndex) {
if (buttonIndex === 1) {
didClickSubmitButton();
} else if (buttonIndex === 2) {
return false;
}
}
function didClickSubmitButton() {
validate();
----some other codes-----
}
function validate() {
navigator.notification.alert("my alert"); // Not working
alert("another alert") //Working
}
I'am testing on iphone simulator of xcode, i need your help. Thanks.
Upvotes: 3
Views: 12848
Reputation: 437
Make sure if you are running it from IDE, that you have added / selected the cordova plugin for your projects in IDE itself.
For example:
If Netbeans, right click on project, select properties, select cordova from tree & click on plugin tabs, check if you have dialogs notification in selected API.
If not that is the reason, each time you will add it from command line and and if try it running from IDE it will erase/clean the plugin directory but will be fine from command prompt only if you make cordova run android.
I hope the above will help.
Upvotes: 0
Reputation: 4293
I faced the same issue in android.
navigator.notification.alert()
was not working but alert()
was working. To customize the alert I wanted navigator.notification.alert()
to work.
So I added the plugin for notification/prompt etc as:
$cordova plugin add org.apache.cordova.dialogs
then added below code to app/config.xml:
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
Thus I got navigator.notification.alert() working with the title, msg, callback and button name parameters.
Upvotes: 2
Reputation: 2701
function validate ()
{
navigator.notification.alert('Mesage',
null,
'Title',
'OK')
}
Upvotes: 1
Reputation: 2479
Your button labels should be enclosed within brackets in array like notation. See the documentation for code examples. http://cordova.apache.org/docs/en/3.1.0/cordova_notification_notification.md.html#notification.confirm
Upvotes: 0