2017-04-21 97 views
0

我正在研究一个具有本地通知插件的科尔多瓦应用程序。我发现在这个混帐:https://github.com/katzer/cordova-plugin-local-notifications科尔多瓦本地通知单击事件参数为空

我有一个问题,当我运行通知的点击事件。正在发生的事件是正在触发事件,但参数通知和状态正在返回空。

通知被触发并且参数正确。我用过的日期过去了吗?

有没有人有同样的问题,并找到了解决办法?

cordova.plugins.notification.local.on("click", function (notification, state) { 

    if (notification.data == null || notification.data == undefined) { } 
    else if (notification.data.localeCompare('') == 0) { 
    } else { 


    } 


}, this); 

NotificationTemplate = function (sheduleTime, id, title, text, process,rowId) { 
var sound = device.platform == 'Android' ? 'file://sound.mp3' : 'file://beep.caf'; 

cordova.plugins.notification.local.schedule({ 
    id: id, 
    title: title, 
    text: text, 
    at: sheduleTime, 
    sound: sound, 
    data: { RowId: rowId, proc: process } 
}); 

};

+0

您的通知是如何构建的?你问题中的代码并没有真正告诉我们很多。 –

回答

1

检查您提到的链接中的语法。您需要使用所需数据安排通知。该示例演示如何安排每周重复的本地通知。监听器将在用户点击本地通知时被调用。

cordova.plugins.notification.local.schedule({ 
    id: 1, 
    title: "Production Jour fixe", 
    text: "Duration 1h", 
    firstAt: monday_9_am, 
    every: "week", 
    sound: "file://sounds/reminder.mp3", 
    icon: "http://icons.com/?cal_id=1", 
    data: {meetingId:"123#fg8"} 
}); 
cordova.plugins.notification.local.on("click", function (notification) { 
    joinMeeting(notification.data.meetingId); 
});