getDeliveredNotifications in UNNotificationServiceExtension failed because of missing entitlement

Hi

I've added new UNNotificationServiceExtension to my application. In the implementation of didReceiveNotificationRequest:withContentHandler: I need to go through all former notification using UNUserNotificationCenter.current().getDeliveredNotifications.

The array of notifications passed to completionHandler has always 0 elements and in the iPhone logs I can see the error: Getting delivered notifications failed because of missing entitlement.

        self.contentHandler = contentHandler
        bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
        if let bestAttemptContent = bestAttemptContent {
            // some notification modifications here...
            contentHandler(bestAttemptContent)
        }
        UNUserNotificationCenter.current().getDeliveredNotifications { notifications in
            for notification in notifications {
                // never executes
            }
        }
    }

I have enabled push notification capabilities for the main target, both targets have set the same App Group.

Any suggestions?

Post not yet marked as solved Up vote post of safarafa Down vote post of safarafa
525 views