开发者

Local notifications will not go away

开发者 https://www.devze.com 2023-02-06 18:33 出处:网络
Yesterday i added local notifications to my app (including repeating ones) and then quite often when i launch the app it pops up the notification. I commented out all the code referring to the local n

Yesterday i added local notifications to my app (including repeating ones) and then quite often when i launch the app it pops up the notification. I commented out all the code referring to the local notifications and it's still doing it. I deleted the app from the simulator too, then re-installed it, and it's still doing this. Any suggestions?

EDIT: It actually appears that it keeps firing the notification onc开发者_StackOverflowe a minute, for some reason.


If you mean UILocalNotification, then add this line to your app and run once

[[UIApplication sharedApplication] cancelAllLocalNotifications];

That will cancel all local notifications your app ever added, including those in prior runs. Related, you can check the scheduledLocalNotifications property of UIApplication as well.


If you haven't added a [[NSNotificationCenter defaultCenter] removeObserver:self] in any view controller that potentially receives a notification and then you pop that view controller off the navigation stack, because it is retained by the notification center, it stays in memory and will continue to respond when the notification comes. I understand you've said you removed the postNotification code, but you must have missed some code somewhere as this can't happen automatically without something calling post notification. What is the message you are receiving? Is it an alert view that pops up? Does it have a custom message or a system message? Find the place where that alert view is displaying and make sure you remove that view controller from the notification center. If it is a system message, figure out what view controller is setup to receive notifications for that system message and make sure *it gets properly removed as an observer from the notification center.

Best regards.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号