嗨,我正在开发cordova App(Cordova 3.4.0)并且想要显示通知。我安装了本地通知插件,如下所述:https://github.com/katzer/cordova-plugin-local-notifications。以某种方式显示通知只能在index.html文件中工作。请看这里:本地通知插件只能在index.html中工作 - 无法读取未定义的属性“通知”
<html>
<head>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/lib/jquery-1.11.0.js"></script>
<script type="text/javascript" src="js/lib/jquery.mobile-1.4.2.js">
<script type="text/javascript">
$(document).ready(function(){
document.addEventListener("deviceready", function() {
// window.plugin.notification.local.add({ message: 'Great app!' }); // Works
location = "nextPage.html";
}, false);
})
</script>
</head>
</html>
但是在调用location =“nextPage.html”;在另一页上完全相同的代码将不再工作。我收到此错误:
错误:无法读取未定义的属性“通知”。
任何想法为什么window.plugin未定义?我的nextPage.html看起来完全像上面的html,除了我注释掉了 - location =“nextPage.html”; - 和 - window.plugin.notification.local.add({message:'Great app!'}); - 。他们在同一个文件夹中,我实现了cordova,jquery和jquery mobile。
我在我的config.xml中此项:
<feature name="LocalNotification">
<param name="android-package" value="de.appplant.cordova.plugin.localnotification.LocalNotification" />
</feature>
任何想法左右我做错了什么?提前致谢。如果您需要更多信息,请告诉我。