簡體   English   中英

UNUserNotificationCenter不能在Swift 3中清除圖標應用程序的通知嗎?

[英]UNUserNotificationCenter not clean notification of icon app in swift 3?

我有個問題。 我在我的應用中收到了一條通知。 我正在嘗試這個。 但是現在,我無法從圖標應用中刪除。

我運行以下代碼:

UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: {requests -> () in
            print("\(requests.count) requests -------")
            for request in requests{
                print(request.identifier)
            }

            UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
        })

        UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler: {deliveredNotifications -> () in
            print("\(deliveredNotifications.count) Delivered notifications-------")
            for notification in deliveredNotifications{
                print(notification.request.identifier)
            }

            UNUserNotificationCenter.current().removeAllDeliveredNotifications()
        })

跟蹤是這樣的:

0個請求------- 0個已發送的通知-------

在圖標應用程序中,我看到以下內容:

我無法顯示圖像:(但在此情況下,我在圖標應用程序和紅色前景上看到了第一名

Yayo,您需要將徽章計數設置為0才能從應用程序圖標中刪除徽章計數。 為了那個原因 -

UIApplication.shared.applicationIconBadgeNumber = 0

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM