如何从单击通知列表中清除单个通知? [英] How to clear a single notification from a list of notifications on clicking?

查看:23
本文介绍了如何从单击通知列表中清除单个通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦我点击一个通知,所有的通知都会被清除.在 ios 中,是否有任何选项可以在点击后清除单个通知?我收到了 4 条通知.现在我需要单独点击通知才能清除并保留其他通知.有人可以帮我吗?

Once i click a notification, all the notifications are cleared.In ios, is there any option to clear a single notification after tapping on it? i have received 4 notifications. now i need the clicked notification alone to get cleared and retain the other ones.Can anyone help me on this?

- (void) clearNotifications {
    [[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
    [[UIApplication sharedApplication] cancelAllLocalNotifications];
}

- (void)application:(UIApplication*)application didReceiveRemoteNotification:(NSDictionary*)userInfo
{    
    NSLog(@"Received notification: %@", userInfo);
    [self clearNotifications];
}

推荐答案

-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{

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

    [[UIApplication sharedApplication] cancelLocalNotification:notification];

}

这篇关于如何从单击通知列表中清除单个通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆