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,
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?