如果添加重定向,则clickova上的cordova-plugin-local-notifications不起作用

时间:2015-12-17 08:16:19

标签: cordova

插件:katzer / cordova-plugin-local-notifications。

通知和“点击”事件正常工作但如果我们在计划后添加重定向,则“点击”事件不会触发...... 这是我的发送提醒功能..

     function add_reminder(notify_list){
        cordova.plugins.notification.local.hasPermission(function(granted){
           if(granted == true){
              cordova.plugins.notification.local.schedule(notify_list);
           }else{
      cordova.plugins.notification.local.registerPermission(function(granted) {
        if(granted == true){
           cordova.plugins.notification.local.schedule(notify_list);
        }else{
           navigator.notification.alert("Reminder cannot be added because app doesn't have permission");
        }
      });
     }
    }); 
    cordova.plugins.notification.local.on("click", function (notification, state) {
       alert(notification.id + " was clicked");
       window.localStorage.setItem("not_sch_id",notification.id);

       window.location.href='main.html';
    }, this);

}

调用代码是..

var sch_not_list=[];
msg="You have medication(s) to take now 00:00 XX" ;
var schedule_time = new Date(('2015-12-16 14:48:00').replace(/-/g, "/")).getTime();
sch_not_list.push({id: 14,title: 'Medicine Reminder',text: msg,at: schedule_time});

add_reminder(sch_not_list);
//..following line causes onclick not working
window.location.href = "main.html";

...从上面的代码中,如果我删除最后一个“window.location.href =”main.html“;”通知和点击事件正常触发。

你能指导我吗?

0 个答案:

没有答案