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

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

问题描述

在我点击一个通知,所有的通知都cleared.In IOS,有没有什么选项轻敲后清除单个通知?我已经收到4通知。现在我一个人需要点击通知得到清除,并保留其他ones.Can任何人帮助我​​在这?

   - (无效){clearNotifications
    [UIApplication的sharedApplication] setApplicationIconBadgeNumber:0];
    [UIApplication的sharedApplication] cancelAllLocalNotifications]
} - (无效)应用:(*的UIApplication)的应用didReceiveRemoteNotification:(NSDictionary的*)USERINFO
{
    的NSLog(@接到通知:%@,用户信息);
    [个体经营clearNotifications]
}


解决方案

   - (无效)应用:(*的UIApplication)的应用didReceiveLocalNotification:(UILocalNotification *)的通知
{//当你在任何通知此委托方法将调用挖掘...    [UIApplication的sharedApplication] cancelLocalNotification:通知]}

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天全站免登陆