blog icon indicating copy to clipboard operation
blog copied to clipboard

How to get notification userInfo at launch

Open onmyway133 opened this issue 2 years ago • 0 comments

When user taps on push notification, depending on app state

SceneDelegate

Checking UIScene.ConnectionOptions.notificationResponse?.notification.request.content.userInfo in scene(_:willConnectTo:options:)

  • app terminated: sometimes nil
  • app in background: notification info

UNUserNotificationCenter

Checking UNNotificationResponse.notification.request.content.userInfo in userNotificationCenter(_:didReceive:withCompletionHandler:)

  • app terminated: notification info
  • app in background: notification info

Read more

  • https://stackoverflow.com/questions/60007715/launchoptions-always-nil-when-launching-from-a-push-notification
  • https://stackoverflow.com/questions/42989932/difference-between-unusernotificationcenterdelegate-and-didreceiveremotenotifica

onmyway133 avatar Jun 01 '22 11:06 onmyway133