Inserting a navigation alert in Phonegap

Asked

Viewed 95 times

0

Hello guys I’m new to phonegap, and for this reason I still have some basic questions. I am writing an example code to appear an alert in the application, but at the moment I will compile the following error appears: Navigator.notification is Undefined Does anyone have any suggestions?

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1,maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>Hello World</title>
</head>
<body>
<h1>Teste</h1>
<input type="button" id="alerta"value="Alerta" onClick="alerta()">
<script type="text/javascript" src="cordova.js"></script>

<script type="text/javascript">

    function alerta() {
        navigator.notification.alert(
            'Phonegap está funcionando!',
            null,
            'Sucesso',
            'Fechar'
        );
    }

 </script>
 </body>
 </html>
  • Take a look at this and see if it helps you. http://stackoverflow.com/questions/20627281/navigator-notification-alert-not-working-phonegap

  • Didn’t help much.

  • Using phonegap build, Cordova or phonegap?

  • I am using Phonegap.

1 answer

0

Hello!

Navigator.notification.Alert is a plugin command. More specifically, this one: https://www.npmjs.com/package/cordova-plugin-dialogs

In order for it to work, you need to register the plugin in your project via CLI as follows:

  • Open the command terminal or prompt;
  • Access your project’s root folder;
  • Add the plugin with: Cordova plugin add Cordova-plugin-dialogs or phonegap plugin add Cordova-plugin-dialogs;

If you don’t, you’ll need to add the requirements manually, which involves changing the config.xml file, cordova_plugins.js, and adding Javascript folders and native languages to each platform in the project. So try to work with the CLI from the start.

I hope it helps. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.