Reputation: 41
I am developing an Android/iOS app with AngularJS and Phonegap Build, using Ripple Emulator in Chrome for local debugging.
navigator.notification.confirm is not working for me, while navigator.notification.alert, navigator.notification.beep and navigator.notification.vibrate are working fine. Chrome says: "Uncaught TypeError: Object [object Object] has no method 'confirm'"
, iOS Simulator just does nothing.
I have <gap:plugin name="org.apache.cordova.core.dialogs" />
and <preference name="phonegap-version" value="3.0.0" />
in my config.xml, and my index.js has the following in the deviceready
callback:
navigator.notification.confirm("Yes or no?", function(){}, "Confirmation", "Yes,No");
Any ideas? Thanks.
Upvotes: 4
Views: 11644
Reputation: 121
There should be no vibrate function in the dialog plugin, only alert, beep, confirm, and prompt. But if you have the vibration plugin installed, then you should see vibrate of course.
If you are only seeing alert, beep, and vibrate, then I would say you have an issue with your plugin installation...something I've seen recently.
I believe this issue works fine for fresh installs, as MBillau mentioned his app worked fine. Installing a plugin on an already existing app seems to have been buggy for me. Here is what I have found out:
I was using 3 plugins (Media, Device, Notification) and Notification was the only one NOT working. Notification also happened after device was ready (I could play media and get device info, then try notification and nothing).
The issue I had was with the way the phonegap CLI was adding plugins.
There was no entry in www/corodova_plugins.js for Notifications, but there was for Media and Device There was no SRC in android/src/org/apache/cordova for Notification, but there was for Media and Device. There was no JS src in www/plugins for dialogs, but there was for media and device.
Check those locations to see if you have the Notifications info.
I tried adding the plugin several times with various commands. config.xml DID include:
{PROJECT.DIR}/plugins DID have dialogs as well as media and device SRC.
WARNING: running "phonegap build android" would place the correct source in the folders mentioned about, but it WIPES OUT all of your src in assets/www .
My remedy: Create a brand new skeleton project, add the plugins you need, do a build for the platform you need, then compare the source between your skeleton Phonegap app and your Real app to see the differences. Only way I can see now as it appears that the PhoneGap CLI is "broken" because I don't believe it is adding plugins correctly to an already existing app.
Upvotes: 0
Reputation: 5376
I just tried with a fresh install (Cordova 3.1.x) and it worked fine without any issues. I installed the plugin myself with cordova plugin add org.apache.cordova.dialogs
, which is a bit different than using phonegap-build. I think this might be an issue with PGB but one suggestion I'll make is to change: <gap:plugin name="org.apache.cordova.core.dialogs" />
to <gap:plugin name="org.apache.cordova.dialogs" />
, that is, remove the .core part, since core was removed from the namespace (might still be there for 3.0 though.)
Upvotes: 2
Reputation: 2569
As mvp said, you need to ensure you have an onDeviceReady function on you page and not call any API's until it has fired.
Additionally, ensure that you have the following in the <head></head
tags of your html page:
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
Upvotes: 1