打开其中一个后,所有通知都会消失 [英] All notifications disappearing after opening one of them
问题描述
我有一个服务器向我发送推送通知,让我们说我手机上有5个通知。如果我打开其中一个,其他所有通知都会消失。我只希望点击一个消失。
I have a server that sends me push notifications and let's say that I have 5 notifications on my phone. If I open one of them all other notifications disappears. I want only the one clicked to disappear.
这是我处理接收通知的方式:
This is how I handle receiving notifications:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
if ( application.applicationState == UIApplicationState.Inactive || application.applicationState == UIApplicationState.Background )
{
// navigating user to a view controller
}
application.applicationIconBadgeNumber = 0
}
推荐答案
通过设置 applicationIconBadgeNumber
到 0
,您还会从通知中心删除所有通知。
By setting the applicationIconBadgeNumber
to 0
, you also remove every notification from the notification center.
这也是这里讨论:
iOS应用程序:如何清除不
此外,无法以编程方式删除单个通知,但是从iOS8开始,当用户点击时,操作系统会为您处理此问题一个通知。这也在这里讨论过:
从通知中心删除单个远程通知
Furthermore, it is not possible to programmatically remove a single notification, but from iOS8 on, the OS will handle this for you when a user taps a single notification. This has also been discussed here: Remove single remote notification from Notification Center
这篇关于打开其中一个后,所有通知都会消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!