Inserting a navigation alert on Phonegap

0

Hello folks I'm new to phonegap, and for this reason I still have some basic questions. I'm writing a sample code to show an alert in the application, but at the moment I'm going to compile the following error appears: navigator.notification is undefined 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>
    
asked by anonymous 29.12.2015 / 00:58

1 answer

0

Hello

navigator.notification.alert is a plugin command. More specifically, this one: link

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

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

If you do not, you will 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 project platform. So try to work with the CLI from the beginning.

Hope it helps. :)

    
20.02.2016 / 17:14