iOS已调用ReceiveRemoteNotification,但Notification pulldown未清除

时间:2014-01-21 16:49:50

标签: ios apple-push-notifications

简单代码:

-(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
}

但是下拉列表仍然包含来自警报的测试。我看到其他程序清除了他们的通知。它是自动的,还是需要编程?我可以在文档中找到任何内容。

1 个答案:

答案 0 :(得分:1)

您可以通过将徽章编号设置为0来清除通知中心中应用的通知,如下所示:

[[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];

此处有更多信息:iOS application: how to clear notifications?