I need to grab data from the payload when receiving a remote push notification, on iOS 9 I did this using the func function: didReceiveRemoteNotification On iOS 10 using swift 3.0 I implemented these 2 functions.
@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()
}
the second fuction is executed only when the user touches the click
I need capture data when a push notification appears, when my application is in the background or even closed.
Sincerely. Hi
source
share