Dismiss an already delivered UILocalNotification?

后端 未结 6 1442
无人及你
无人及你 2020-12-20 14:40

Is it possible to do this? UIApplication\'s scheduledLocalNotifications doesn\'t seem to return notifications that have already been delivered to t

6条回答
  •  温柔的废话
    2020-12-20 15:25

    Since iOS10 there is now native support for this if you have transitioned to using UNUserNotificationCenter.

    The Apple docs state:

    func getDeliveredNotifications(completionHandler: @escaping ([UNNotification]) -> Void)

    Provides you with a list of the app’s notifications that are still displayed in Notification Center.

    func removeDeliveredNotifications(withIdentifiers: [String])

    Removes the specified notifications from Notification Center.

    func removeAllDeliveredNotifications()

    Removes all of the app’s notifications from Notification Center.

提交回复
热议问题