Robson Braga
Robson Braga

Reputation: 342

PhoneGap 3.0 - Cannot call method 'confirm' of undefined

I'm trying to call phonegap's method navigator.notification.confirm, but I only get the error Cannot call method 'confirm' of undefined

I've added the necessary plugins:

phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git

and permissions:

// in www\config.xml
<feature name="Notification">
    <param name="android-package" value="org.apache.cordova.Notification" />
</feature>

// in platforms\android\AndroidManifest.xml
<uses-permission android:name="android.permission.VIBRATE" />

My code is:

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
    <script type="text/javascript" charset="utf-8">
      document.addEventListener("deviceready", onDeviceReady, false);

      function onDeviceReady() {}

      function onConfirm(buttonIndex) {
          alert('You selected button ' + buttonIndex);
      }

      function showConfirm() {
        try {
          navigator.notification.confirm(
            'You are the winner!',
            onConfirm,
            'Game Over',
            'Restart,Exit'
          );
        } catch(e) {
          alert('Exception: ' + e.message);
        }
      }
    </script>
  </head>
  <body onLoad="showConfirm();"></body>
</html>

What am I missing?

Upvotes: 2

Views: 1625

Answers (1)

Robson Braga
Robson Braga

Reputation: 342

Problem solved.

I had to remove the plug-ins and add it again by phonegap command line utility...

Upvotes: 1

Related Questions