0

I am trying to implement local noti operation on my mobile app. I can successfully schedule the notification but cannot get the "trigger event".

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

When it's the time, local notification works but cannot catch the trigger event so that badge count doesn't increase.. How can I solve this? thanks in advance!

nextdoordoc
  • 1,727
  • 6
  • 20
  • 30

1 Answers1

0

Maybe you have to use

cordova.plugins.notification.local.on({ ... }) instead LocalNotifications.on.

Use it after platform is ready and it will be ok.