如何从点击通知列表中清除单个通知?
Posted
技术标签:
【中文标题】如何从点击通知列表中清除单个通知?【英文标题】:How to clear a single notification from a list of notifications on clicking? 【发布时间】:2013-06-14 11:57:22 【问题描述】:一旦我点击一个通知,所有的通知都会被清除。在ios中,是否有任何选项可以在点击后清除单个通知?我收到了 4 条通知。现在我只需要点击通知来清除并保留其他通知。有人可以帮我吗?
- (void) clearNotifications
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
NSLog(@"Received notification: %@", userInfo);
[self clearNotifications];
【问题讨论】:
在clearNotifications:
cancelAllLocalNotifications: 将取消所有通知...
【参考方案1】:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
// when you tap on any of notification this delegate method will call...
[[UIApplication sharedApplication] cancelLocalNotification:notification];
【讨论】:
以上是关于如何从点击通知列表中清除单个通知?的主要内容,如果未能解决你的问题,请参考以下文章