0
我試圖在我的移動應用程序上實現本地noti操作。我可以成功安排通知,但無法獲得「觸發事件」。Ionic2,LocalNotification插件,觸發事件不起作用
constructor(public platform:Platform, public nav:NavController, public navParams:NavParams,
public builder:FormBuilder, public menu:MenuController, public verify:VerifyToken) {
// after local noti alert trigger, badge number increases 1
LocalNotifications.on("trigger", (notification, state) => {
this.nav.present(alert);
// badge number increase 1.
Badge.increase(1);
});
// local push for alarming 30mins before reservation
LocalNotifications.on("click", (notification, state) => {
// badge number 0
Badge.clear();
let alert = Alert.create({
title: "scheduled!",
subTitle: "scheduled!",
buttons: ["OK"]
});
this.nav.present(alert);
});
}
scheduleAppointment() {
LocalNotifications.schedule({
title: "scheduled!,
text: "ready to go!",
at: moment(this.reservation.start).subtract(1800, 'seconds').toDate()
});
}
當時間到了,本地通知工作,但無法捕捉觸發事件,因此徽章計數不會增加。如何解決此問題?提前致謝!