Search code examples
iosswiftuilocalnotification

Determine if local notification has been triggered


2 questions that I can't find answers:

1: How to determine if local notification has been triggered?

2: Are the local notification deleted after being triggered?


Solution

  • You should not be using UILocalNotification. The modern way is UNNotification.

    You can examine the contents of the UNUserNotificationCenter. Call

    getPendingNotificationRequests(completionHandler:)
    

    of

    getDeliveredNotifications(completionHandler:)
    

    A notification that has been delivered but not yet removed from the notification center (history) is in the second group.