Quantcast
Channel: Developer Feed - Snippet
Viewing all articles
Browse latest Browse all 178

How to clear the iPhone number badge when the Push Notification Alert is recieved?

$
0
0

Snippet

When the push notification is received, the didReceiveRemoteNotification method of the App Delegate is called and then we can perform the required action and clear the badge.

  1. /**
  2.  * Remote Notification Received while application was open.
  3.  */
  4. -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary*)userInfo {
  5.        
  6.         #if !TARGET_IPHONE_SIMULATOR
  7.          NSString*badge =[apsInfo objectForKey:@"badge"];
  8.         NSLog(@"Received Push Badge: %@", badge);
  9.  
  10.          // set it to Zero will clear it.
  11.          [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
  12.        
  13.         #endif
  14. }

Viewing all articles
Browse latest Browse all 178

Trending Articles