【问题标题】:Ionic2, LocalNotification plugin, trigger event not workingIonic2,LocalNotification 插件,触发事件不起作用
【发布时间】:2016-08-07 15:08:10
【问题描述】:

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

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

到了时间,本地通知有效,但无法捕获触发事件,因此徽章计数不会增加。我该如何解决这个问题?提前致谢!

【问题讨论】:

    标签: triggers ionic2 localnotification


    【解决方案1】:

    也许你必须使用

    cordova.plugins.notification.local.on({ ... }) 而不是LocalNotifications.on

    平台准备好后使用就OK了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-10
      • 2013-01-05
      • 2012-12-09
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多