嗨,我正在開發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>
任何想法左右我做錯了什麼?提前致謝。如果您需要更多信息,請告訴我。