我正在使用此插件并尝试使用Local notifications plugin触发我的Cordova iOS应用的本地通知。
我遵循以下步骤:
已安装的插件:cordova plugin add de.appplant.cordova.plugin.local-notification@0.7.7
更新了 config.xml :gap:plugin name="de.appplant.cordova.plugin.local-notification"
在
的index.html
plugin.notification.local.promptForPermission(function (granted) {
alert("promptForPermission: "+granted);
});
plugin.notification.local.hasPermission(function (granted) {
alert("hasPermission: "+granted);
});
代码如下:
function setLocalNotification()
{
alert("from setLocalNotification");
var t = new Date();
t.setSeconds(t.getSeconds() + 3);
window.plugin.notification.local.add({
title: 'Scheduled with delay',
message: 'Test Message ',
date: t
});
alert("alert set");
};
我确实看到了用户许可的提示,并且来自hasPermission方法的警报将值显示为true。但是我仍然无法通过单击按钮获得我尝试设置的实际本地通知。我已经通过复制this issue修正更新了this的 APPLocalNotification.m 文件。
我在控制台日志中没有看到任何更多错误,但我仍然无法触发本地通知。
答案 0 :(得分:0)
您应该检查设备是否准备就绪(document.addEventListener(' deviceready',function(){ 并检查插件是否正确添加$ cordova plugin ls。
确保你有"<脚本类型=" text / javascript" SRC =" cordova.js"> "在你的HTML中。
祝你好运!