ios - Swift: launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] returning nil even if notification exists -


i'd display popup user in following scenarios:

1) user has app open , notification received - working fine

2) user has app closed, notification received, , user reopens app - not working

3) user has app running in background , brings app foreground - not working

to address #2, here code, trimmed relevance:

func application(_ application: uiapplication, didfinishlaunchingwithoptions launchoptions: [uiapplicationlaunchoptionskey: any]?) -> bool {      uiapplication.shared.isstatusbarhidden = true     unusernotificationcenter.current().delegate = self     registerforpushnotifications()      print("launch options")     print(uiapplication.shared.applicationiconbadgenumber)     print(launchoptions)     if let remotenotification = launchoptions?[uiapplicationlaunchoptionskey.remotenotification] as? nsdictionary {         print("notification payload")         print(remotenotification)      }      return true } 

i haven't gotten point i'm doing payload. issue print(launchoptions) returns nil every time, doesn't matter put inside if let statement. missing something?

it seems easiest solution have notification payload accessible outside of didfinishlaunchingwithoptions. use same solution address #2 , #3 above, can't find on that.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -