我已经安装了科尔多瓦本地通知插件在我的应用程序的本地通知。但是我无法得到通知的行为在我的代码工作。
这里是我的代码。
scheduleTime: String = '08:15'; //default
scheduleAlarm(){
this.date = this.datePipe.transform(this.date,"yyyy-MM-dd");
var reminder_date = new Date(this.date+" "+this.scheduleTime);
var hours = reminder_date.getHours();
var minutes = reminder_date.getMinutes();
if(reminder_date){
cordova.plugins.notification.local.schedule({
id: 1,
text: 'My first notification',
trigger: {at: reminder_date},
actions:[{id: 'yes', title: 'Yes'},{id:'no',title:'No'}]
})
this.showAlert('Reminder is set successfully');
}
cordova.plugins.notification.local.on("yes",function(notification){
alert(notification.id);
});
}
点击后是什么也没发生,只是通知被解雇。我是不是正确处理呢?可有人请帮助我?
你必须启动属性添加到你的行动阵列和布尔设置为true。
cordova.plugins.notification.local.schedule({
id: 1,
text: 'My first notification',
trigger: {at: reminder_date},
actions:[{id: 'yes', title: 'Yes', launch: true},{id:'no',title:'No'}]
})
所以,当你点击是的,这将启动应用程序。