如何在通知中心删除特定的远程通知 [英] How to remove specific remote notification in the notification center
问题描述
我们都知道,此方法[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屋!