I have an app written in Swift that uses UNUserNotificationCenter and I have it presenting notifications when the app is in the foreground.
What I want to do is update the UI once the notification has been delivered and the app is in the foreground The following presents the notification just fine, but when it is presented, I also want to execute a function called updateUI() as the notification date is in my UI and I want to clear it as soon as the notification appears.
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert,.sound])
}
I don't know how to add the call to updateUI() in the completion handler.