Ionic2,LocalNotification插件,触发事件不起作用

时间:2016-08-07 15:08:11

标签: triggers ionic2 localnotification

我正在尝试在我的移动应用上实施本地noti操作。我可以成功安排通知,但无法获得“触发事件”。

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()
    });
  }

当它是时候,本地通知有效,但无法捕获触发事件,因此徽章数量不会增加..我该如何解决这个问题?提前谢谢!

1 个答案:

答案 0 :(得分:0)

也许你必须使用

.owl-prev { width: 15px; height: 100px; position: absolute; top: 40%; margin-left: -20px; display: block !important; border:0px solid black; } .owl-next { width: 15px; height: 100px; position: absolute; top: 40%; right: -25px; display: block !important; border:0px solid black; } .owl-prev i, .owl-next i {transform : scale(1,6); color: #ccc;} 代替cordova.plugins.notification.local.on({ ... })

平台准备就绪后使用它就可以了。