navigator.notification.confirm not working in android (PhoneGap 3.3)

1,236 views
Skip to first unread message

Christian Puritscher

unread,
Feb 26, 2014, 11:16:27 AM2/26/14
to phon...@googlegroups.com
I have a problem with navigator.notification.confirm, it seems the plugin is not properly loaded and I have no idea why.

I am using eclipse to deploy the app on a emulator, and I keep getting the message:

02-26 15:59:59.933: E/Web Console(1368): Uncaught TypeError: Cannot call method 'confirm' of undefined at file:///android_asset/www/index.html:53

when trying to call navigator.notification.confirm. The appropriate code is here:

<script type="text/javascript" charset="utf-8">
        // Wait for PhoneGap to load
        document.addEventListener("deviceready", onDeviceReady, false);

        // PhoneGap is ready
        function onDeviceReady() {
            initialize();
        }
       
        function initialize() {
            askForUpdateDatabase();
        }
       
        function askForUpdateDatabase() {
           
 
           navigator.notification.confirm("Der Datenbestand ist veraltet. Soll eine neue Version heruntergeladen werden?",
askedForUpdateDatabase, "Update?", ["Ja", "Nein"]);
        }

        function askedForUpdateDatabase(select) {
            if (select==1) updateDatabase();
        }
       
        function updateDatabase() {
            alert("Aktualisiere Datenbank...");
        }

The important parts of the config.xml:
    <feature name="Geolocation">
       
<param name="android-package" value="org.apache.cordova.geolocation.GeoBroker" />
   
</feature>
   
<feature name="Vibration">
       
<param name="android-package" value="org.apache.cordova.vibration.Vibration" />
   
</feature>
   
<feature name="Notification">
       
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
   
</feature>


And the output of the installed phonegap plugins:
D:\apps\MYAPP>phonegap plugin list
[phonegap] org.apache.cordova.dialogs
[phonegap] org.apache.cordova.geolocation
[phonegap] org.apache.cordova.vibration

D
:\apps\MYAPP>phonegap version
3.3.0-0.19.6


The geolocation plugin works perfectly, but I cannot fix the dialogues. It also won't work when removing it from the phonegap-ready event and calling it directly on a button.

Does anyone have an idea what the problem is?

Thanks in advance

Venkatesh Naidu

unread,
Oct 21, 2014, 4:30:39 AM10/21/14
to phon...@googlegroups.com
Me too getting same error..

Horst

unread,
Oct 21, 2014, 11:49:42 AM10/21/14
to phon...@googlegroups.com
The original posting is some month old. But i have also troubles with the actual plugin on older Android versions. I have found a 13 day old commit for "unbeaking" Dialogs plugin on Android for API lower 14:
https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-dialogs.git;a=commit;h=4cfe290b2a3e8f0aafb71a1ff4fbee4b710c8749

Maybe this is also your problem?

best regards
Horst
Reply all
Reply to author
Forward
0 new messages