[英]PhoneGap: Local Notifications are not working on iOS
我目前正在嘗試為Android和iOS構建應用程序,該應用程序應該能夠向用戶發送本地通知。
我已經設法在Android上發送了本地通知,但無法在iOS上運行。
當我在iOS 9上啟動該應用程序時,iPhone會顯示一個提示,要求我允許該應用程序發送通知。 允許應用發送通知后,仍然沒有通知。
在Android上:啟動應用程序-> 帶有文本“確定”的通知
在iOS 9上:啟動應用程序->允許發送通知-> 沒有通知
我還嘗試向應用程序添加一個按鈕,該按鈕觸發Notifier.notify('test')
但這沒有用。
我什至創建了新的Apple證書和配置文件。
我正在使用此插件: https : //github.com/katzer/cordova-plugin-local-notifications
並嘗試了這個: https : //build.phonegap.com/plugins/4859
我正在使用PhoneGap Build服務來構建應用程序。
有誰知道為什么它可以在Android上運行而不能在iOS上運行?
我的代碼:
config.xml文件:
...
<plugin name="cordova-plugin-local-notifications-mm"/>
...
index.html的:
<script src="cordova.js"></script>
<script src="local-notification.js"></script>
<script src="js/index.js"></script>
<script src="js/notify.js"></script>
index.js:
var app = {
initialize: function () {
this.bindEvents();
},
bindEvents: function () {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function () {
Notifier.registerPermission();
}
};
app.initialize();
notify.js:
var Notifier = {
registerPermission: function () {
window.plugin.notification.local.registerPermission(function (granted) {
Notifier.notify('OK');
});
},
notify: function (message) {
var now = new Date();
window.plugin.notification.local.add({
id: parseInt(new Date().getTime()),
message: message,
date: now
});
}
};
剛剛完成了一個ibeacon應用程序,該應用程序可以在ios和android上運行,並且即使在關閉應用程序或重新啟動電話的情況下也可以發出通知。
確保添加:
cordova.plugins.locationManager.requestAlwaysAuthorization();
那就是為我做的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.