Local Notification triggers and clearing?

I have created a NotifyService which handles all my local notifications in my app.

I have a lot of them since its its like a task list which the user can setup individual reminders for each task.
The notifications are recurring and it could be on some days that the notification should not show…for eg if a user has already checked off the task for that day, the notification should not show

In my prototype I achieved that by simply adding an event listener on the trigger event. When the notification was triggered I would check the status of that task and if complete I would call LocalNotifications.clear on that notification and it would clear away completely.

Now implementing this properly I am having problems.
As mentioned my notification management is all in a service. Where is the corect place to put the Event Listener?
If I put it into the service constructor the event listener doesnt ever get called.
If I put it on one of the app pages then it does get called but it seems to get called multiple times??

see below…this is the console when a single notification is triggered,
image

And whats more concerning…even though I am calling Notification.clear and getting a successful response - the notification is not being cleared. Something tells me that it has something to do with the multiple event listeners being triggered.

In ionic2 or angular1 i would have just added the event onto the rootScope but not sure what the correct approach for ionic2/angular2.

Anyone got any advice or guidance?

Is nobody using local notifications?

This is really just a simple question of how to setup local notification event listeners in a way that works?

Anyone else have this working?

Have you seen this ?

Of course…thats what I am using. The docs describe the event listeneres I am talking about but nothing helpful in terms of implementation.

Again my main (first) problem is that the the intialization of the event listeners will only work when running from the page on which the notification was scheduled but not from any service. Which doesnt make sense!
Someone must have had this issue or have it working on a service??

This could of some use.

Yes have seen that. It’s pretty basic. He doesnt touch event listeners

I don’t understand what this means. You’re saying you inject the service into your home page (or wherever) and that line of the constructor is never executed?

I might divert the topic but below is the trigger i am using.
As required i too need recurring notifications, for e.g. Hourly at particular minutes every 58th min.

let notification = {
  id: new Date().getTime(),
  title: 'Thinking Healthy!',
  text: 'Order Placement.',
  badge: 1,
  trigger: {
    count: 1,
    every: { minute: 58, seconds: 0}
  },
  launch: true,
  lockscreen: true,
  data: 'Kindly place your Order today.',
  vibrate: true
};

 if (this.platform.is('cordova') && (this.platform.is('android') || this.platform.is('ios')))  {
  // alert('I am an Android/ios device!');
  this.localNotifications.cancelAll().then(() => {
    // alert("Scheduling notification");
    this.localNotifications.schedule(notification);
  });

  this.localNotifications.on('click')
  .subscribe(notification => {
    alert(notification.data);
  });
}

If i remove the ‘count’ attribute for trigger, it will make the notification but will go on infinite notifications, sounds, vibrations etc and App crashes.

Count: 1 makes it work for first time, but i need to wait for another hour to check if second goes well or not.

Note: I am scheduling the notification in Home Page ionViewDidLoad() method.

Suggestions please welcome.