Reputation: 369
I have an iOS app written in objective c. I am facing issues with cluttering of notifications in the notification area. The local notifications will be triggered after every hour. If the user doesn't click on the notification, the next notification would also be added on to the notification area which we don't want. What we want is, to cancel the previous notifications and pop up a new notification every time, so that we only have one notification, instead of seeing multiple notifications getting lined up in the notification area. Any help is greatly appreciated. Thank you in advance
Upvotes: 0
Views: 57
Reputation: 1293
Just before scheduling your next local notification clear the previous notifications
//to clear the alarm notification from notification center
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 1];
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
Upvotes: 0
Reputation: 12820
You cannot control how the notifications are handled by the OS. You also cannot control locally whether the user opened the app or not and customize the behaviour of the scheduled notifications.
What you can do however, is to track on the server whether the user logged in (or did whatever you need to be done in order to continue posting notification) and then schedule (remote) notifications based on that.
I know that this might not solve your problem, but I think this might lead you into the right direction (given that you control your server-side code and are willing to go with remote notifications as opposed to local ones...)
Upvotes: 0