1

simple code:

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
  return YES; 
}

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  NSLog(@"%@", deviceToken);
  // code that sends token to server
}

-(void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  NSLog(@"%@", deviceToken);
  // code that sends token to server
}

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
 // put up an alert with notification text
}

But the dropdown still contains the test from the alert. I see other programs clearing their notifications. Is it automatic, or programming required? I could find anything in the documentation.

Ilario
  • 5,979
  • 2
  • 32
  • 46
Paul
  • 316
  • 2
  • 12

1 Answers1

1

You can clear your apps's notifications in notification center by setting the badge number to 0 like this:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

More info here: iOS application: how to clear notifications?

Community
  • 1
  • 1
Edwin Iskandar
  • 4,119
  • 1
  • 23
  • 24
  • I had to do setApplicationIconBadgeNumber:1, setApplicationIconBadgeNumber:0 to get it to work... Clear the local notifications wasn't needed. – Paul Jan 21 '14 at 21:32