【问题标题】:UNUserNotificationCenter not clean notification of icon app in swift 3?UNUserNotificationCenter 在swift 3中没有清除图标应用程序的通知?
【发布时间】:2018-03-12 23:24:49
【问题描述】:

我有问题。我的应用程序中有一条通知。我正在尝试这个。但现在,我无法从图标应用程序中删除。

我运行这段代码:

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 发送通知-------

在图标应用中,我看到了这个:

Im can't up image :( but in this, i see a number one on the icon app and red foreground

【问题讨论】:

    标签: ios swift3 ios11 xcode9


    【解决方案1】:

    Yayo,您需要将徽章计数设置为 0 以从您的应用图标中删除徽章计数。为此 -

    UIApplication.shared.applicationIconBadgeNumber = 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-14
      • 2017-11-03
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      • 2021-09-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多