【发布时间】:2014-06-03 09:01:10
【问题描述】:
我已经安装了这样的通知插件:
phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
然后我在/www/文件夹中添加了config.xml:
<feature name="Notification">
<param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
我已经尝试在我的index.html 中测试这样的插件:
document.addEventListener("deviceready", onDeviceReady, true);
function onDeviceReady() {
alert('Device ready');
var beep = function(){
try{
if(navigator != null){
navigator.notification.alert("2");
}else{
alert(navigator);
}
}catch(e){
alert("Alert failed: " + e.message);
}
}
beep();
}
但我总是收到“警报失败”作为 navigator.notification 未定义的消息。
我正在使用 phonegap 3.3.0-0.19.6 并使用 phonegap local build android 构建项目
我错过了什么?
【问题讨论】:
-
没有来自 logcat 的其他消息?例如,官方文档说你应该在你的 Manifest 文件中添加一个特定的权限
<uses-permission android:name="android.permission.VIBRATE" />。可能这仅与振动有关,但实际上文档中没有任何内容说此权限不是强制性的。 -
感谢 lorenzo,但我没有在任何地方提到
vibration字 :) 如果我使用 @987654332,我只对显示自定义警报通知感兴趣,而不是使用出现在 Android 上的标准黑色通知@ -
我喜欢没有 cmets 的投反对票 :)
标签: cordova