I have to fire two different experiments when app is in background state,
- When notification arrives to user but not tap yet. (this is not achieve)
- Out of all notifications, how many time user tap on notification alerts and open app. (this is achieved)
I used below methods : When the user responds to a notification by tap on alert message, the system calls below method with the results.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
If your app is in the foreground and a notification arrives, the notification center calls below method to deliver the notification directly to your app.
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)