Cordova navigator.notification.alert() doesn't work (android)

时间:2015-06-25 19:07:15

标签: javascript android cordova

I am using cordova 5.0.0. I have added the notifications plugin, but navigator.notification.alert(.) still doesn't work. I add a plain alert() in front of the navigator.notification.alert(), the regular alert works, but this doesn't. I saw there were some posts about this issue on stackoverflow, unfortunately, the solutions cannot help at my side. Thanks a lot for any help!

3 个答案:

答案 0 :(得分:0)

确认您在生成的config.xml中正确安装了插件。你应该看到这样的东西:

<feature name="Notification">
    <param name="ios-package" value="CDVNotification" />
</feature>

确保你正在调用这个插件:

function alertDismissed() {
    // do something
}

navigator.notification.alert(
    'You are the winner!',    // message
    'alertDismissed',         // callback
    'Game Over',              // title
    'Done'                    // buttonName
);

答案 1 :(得分:0)

我在index.html中添加<script src="cordova.js"></script>(在所有其他脚本标记之前),现在可以使用了。{/ p>

答案 2 :(得分:0)

请在使用此插件前检查其可用性。

if(navigator.notification == undefined)
{
        alert(msg);
        return false;
}
else
{
navigator.notification.alert(message, 
                             callback, 
                             title,
                             buttonName);
}