简体   繁体   中英

Ios notification cluttering on notification area

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

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...)

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM