【问题标题】: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: 将取消所有通知...

标签: iphone ios objective-c push-notification apple-push-notifications


【解决方案1】:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{

// when you tap on any of notification this delegate method will call... 

    [[UIApplication sharedApplication] cancelLocalNotification:notification];

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多