Notification.alert不工作在phonegap build 3.1.0 [英] Notification.alert is not working in phonegap build 3.1.0

查看:151
本文介绍了Notification.alert不工作在phonegap build 3.1.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个phonegap应用程序。我使用notification.alert显示消息。在更新phonegap 3.1.0之前notification.clert工作正常。正如我已经做了约5个应用程序使用phonegap 2.9.0。在每个应用程式中,我使用了来自的notification.alert

I am creating a phonegap application. I have used notification.alert to show messages. Before updation of phonegap 3.1.0 the notification.clert was working fine. As i have done about 5 app using phonegap 2.9.0. In every app i have used notification.alert from this

现在我已经建立我的工作项目在2014年1月28日,它只显示3个应用程序(Iphone,Android和Windows)可以使用phonegap。我正在为IOS和Android创建。一切都工作正常,除了警报。在新的phonegap有什么问题吗?是否有任何新的方法或命令显示警报消息?

Now i have build my working project on 28th jan 2014, It is showing only 3 apps (Iphone, android and windows) can be done using phonegap. I am creating for IOS and Android. Everything is working fine except alert. Is there any problem in new phonegap? Is there any new method or command to show alert messages?

请帮助我为什么它不工作。如果你有任何其他想法,那么请帮助我。

Please help me why it is not working. If you have any other idea then please help me.

推荐答案

从3.0版本开始,Phonegap / Cordova实现设备级API作为插件,所以你必须包括在你的配置。在www文件夹中找到xml

As of version 3.0, Phonegap/Cordova implements device-level APIs as plugins so you have to include this in your config.xml found in the www folder

<gap:plugin name="org.apache.cordova.dialogs" />

或者从phonegap CLI手动添加:

or add it manually from the phonegap CLI like this:

 $ cordova plugin add cordova-plugin-dialogs
 $ cordova plugin ls
    [ 'org.apache.cordova.dialogs' ]
 $ cordova plugin rm org.apache.cordova.dialogs

包括它之后,你可以使用这样

After you include it you can use like this

<!DOCTYPE html>
<html>
  <head>
    <title>Notification Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // device APIs are available
    //
    function onDeviceReady() {
        // Empty
    }

    // alert dialog dismissed
        function alertDismissed() {
            // do something
        }

    // Show a custom alertDismissed
    //
    function showAlert() {
        navigator.notification.alert(
            'You are the winner!',  // message
            alertDismissed,         // callback
            'Game Over',            // title
            'Done'                  // buttonName
        );
    }

    </script>
  </head>
  <body>
    <p><a href="#" onclick="showAlert(); return false;">Show Alert</a></p>
  </body>
</html>

您可以进一步研究此处。快乐编码!

You can research further here . Happy coding!

这篇关于Notification.alert不工作在phonegap build 3.1.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆