I commented that I have migrated my swift app 2.3 to 3.0 and I am working with Xcode 8. with the previous versions I could capture the payload of a push notification using the function: didReceiveRemoteNotification.
I have been trying for several days to capture the payload of the push notification when the app is in background or even closed. I have implemented this:
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
print("\(notification.request.content.userInfo)")
completionHandler([.alert, .badge, .sound])
}
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
{
print("User Info = ",response.notification.request.content.userInfo)
completionHandler()
}
but it seems that the second function only responds when the app is opened from the push.
How can I capture the payload information when the app is in background or closed?