Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clearing the badge when received Push Notification

How can I clear the badge which appears on application icon when I receive Push Notification? I want to clear it once user has either tapped on "View" of Push notification alert or has tapped on the app icon.

like image 252
Abhinav Avatar asked Apr 28 '11 21:04

Abhinav


2 Answers

I suspect you are talking about the SpringBoard's badge:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]
like image 125
Pier-Olivier Thibault Avatar answered Sep 18 '22 06:09

Pier-Olivier Thibault


Badge count set Zero

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]

Cancel all local notifications with this code:

[[UIApplication sharedApplication] cancelAllLocalNotifications];

Cancel one local notification with this line of code:

[[UIApplication sharedApplication] cancelLocalNotification:theNotification];

here theNotification is a UILocalNotification object, so in order to cancel a specific notification, you need to hold on to it's UILocalNotification.

Check this.

like image 24
Sudhakar Avatar answered Sep 18 '22 06:09

Sudhakar