Hi,I'm facing the same issue in iOS 13.3.1 calling those methods insideoverride func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void)of UNNotificationServiceExtension class.Have you found any solutions / workaorunds? Thanks.--T
Post
Replies
Boosts
Views
Activity
I found the solution and now it's working properly.As described here:https://developer.apple.com/documentation/usernotifications/unusernotificationcenter/1649520-getdeliverednotificationsThe completionHandler is executed on background thread and the array of notifications cloud not be ready immediatelly.I used a DispatchSemaphore in order to wait and get the notiification array.let semaphore = DispatchSemaphore(value: 0)let center = UNUserNotificationCenter.current() let customID = data["custom-payload-id"] as? String ?? "-1";center.getDeliveredNotifications { notifications in // background Thread here let matching = notifications.first(where: { notify in let id = userInfo["custom-payload-id"] as? String return id == customID }) if let matchExists = matching { center.removeDeliveredNotifications( withIdentifiers: [matchExists.request.identifier]) } semaphore.signal() }// main thread here semaphore.wait()--T