如何在通知中心移除特定的远程通知 [英] How to remove specific remote notification in the notification center

查看:30
本文介绍了如何在通知中心移除特定的远程通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们都知道这个方法 [UIApplication sharedApplication].applicationIconBadgeNumber = 0; 可以从通知中心移除我们应用程序的所有远程通知.但是,出于某种原因,我想删除用户点击通知中心的那个,而保留其他的.

We all know that this method [UIApplication sharedApplication].applicationIconBadgeNumber = 0; could remove all remote notifications of our application from the notification center. However, for some reason, I want to remove the one which user taps on the notification center, and leave the others.

有什么方法可以做到吗?

Does it have any method to do it?

推荐答案

如果您只是想从徽章编号中删除一个数字:

If you're simply looking to remove one number from the badge number:

[UIApplication sharedApplication].applicationIconBadgeNumber = MAX([UIApplication sharedApplication].applicationIconBadgeNumber - 1, 0);

如果您要问如何以编程方式从通知中心删除单个通知,则无法在代码中完成.显然,在 iOS8 中,当用户点击它时,操作系统将删除单个通知.否则不可能由你处理.

If you're asking how to programmatically remove a single notification from notification center, it can't be done in code. Apparently in iOS8 the OS will remove a single notification when a user taps on it. Otherwise it's not possible to be handled by you.

参见:https://stackoverflow.com/a/10569847/620577

这篇关于如何在通知中心移除特定的远程通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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