I have a provider which sends Push notifications to my iPhone. If I'm on home screen, I click on push notification in notification center and my app become open. Then I close my app, but notification is still in notification center...Why ? I already read that, why its not disappear ? How to remove this notification after I close my app ??
Asked
Active
Viewed 2,703 times
0
-
2possible duplicate of [iOS application: how to clear notifications?](http://stackoverflow.com/questions/8682051/ios-application-how-to-clear-notifications) – Suresh Varma Aug 17 '12 at 10:49
2 Answers
1
WHen are you want to remove the badge from the application just value of the badge number assign to 0 is means automatically remove the badges.
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}

Nimit Parekh
- 16,776
- 8
- 50
- 72
-
But I dont want to set my badge to 0. What if I have badge with 43 unread messages in app, and then I have one new push notification, i should set badge 0 instead of 44 ? – Jim Aug 17 '12 at 10:49
-
Hello Jim, In means when the application come form background then it's badge value being 0; – Nimit Parekh Aug 17 '12 at 10:51
-
For that we put this code into appdelegate inside applicationWillEnterForeground method. – Nimit Parekh Aug 17 '12 at 10:52
0
You can remove the notifications using the below code
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
This will remove all the app's notification from Notification Center.

Suresh Varma
- 9,750
- 1
- 60
- 91
-
But I dont want to set my badge to 0. What if I have badge with 43 unread messages in app, and then I have one new push notification, i should set badge 0 instead of 44 ? – Jim Aug 17 '12 at 10:49