如何清除徽章数量,同时preserving通知中心 [英] How to clear badge number while preserving notification center
问题描述
我用 [UIApplication的sharedApplication] setApplicationIconBadgeNumber:0]
清除证件号码。它工作正常,但远程通知在同一时间将被删除。
I use [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0]
to clear badge number. It works fine but remote notifications are removed at the same time.
有许多其他的问题,清除通知中心,但我不希望以清除它们。我只是想清楚了,而preserving通知徽章的数量。
There are many other questions to clear notification center but I would NOT like to clear them. I just want to clear number of badge while preserving notifications.
有没有办法实现这一目标?
Is there any way to achieve this?
推荐答案
一个哈克的办法解决这是徽章数量设置为负值。负值并不在主屏幕上显示,并因为他们是非零的,它们不会导致通知中心得到清除。
One hacky way around this is to set the badge count to a negative value. Negative values aren't shown on the home screen and since they're non-zero, they don't cause the notification center to get cleared.
尝试 [UIApplication的sharedApplication] setApplicationIconBadgeNumber:-1]。
,看看它是否会导致您需要的用户面临着行为
Try [[UIApplication sharedApplication] setApplicationIconBadgeNumber:-1]
and see if it results in the user facing behavior that you want.
这篇关于如何清除徽章数量,同时preserving通知中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!