When I send out a PUSH notification to my app, it stays in the notification center in iOS 5. How can I remove the notification from the notification center from within the app?
Asked
Active
Viewed 2,276 times
2 Answers
6
Clearing the badge clears the notifications from the notification center.
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Clear application badge when app launches
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
This only works if the number changes. So to make it work in case badge is already zero, set it to some value and clear it again after a delay.
- (void)applicationWillEnterForeground:(UIApplication *)application {
if([[UIApplication sharedApplication] applicationIconBadgeNumber] == 0)
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:1];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Clear application badge when app launches
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
}
Doesn't work if you set and clear in the same method.

Dare2Dream
- 474
- 5
- 14
-1
It is not possible to remove the notification from the notification center from within the app because in iOS5, notifications properties are displayed by apps, in :
Settings -> Notifications -> The app -> Notification Center (YES/NO).

Michaël
- 6,676
- 3
- 36
- 55
-
Are you sure? It seems like some apps do it. And Apples apps does it, like Messages, Mail, etc. – brange Nov 11 '11 at 12:07