Push Notification -didFinishLaunchingWithOptions

后端 未结 5 1446
[愿得一人]
[愿得一人] 2020-12-05 15:24

When I send a push notification and my app is open or in the background and I click on the push notification, my application redirects to PushMessagesVc v

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 16:05

    Swift 5

    To get push notification Dictionary in didFinishLaunchingWithOptions when app is kill and push notification receive and user click on that

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: AnyObject] {
            if let aps1 = userInfo["aps"] as? NSDictionary {
                print(aps1)
            }
        }
        return true
    }
    

    Push notification Dictionary will display in alert.

提交回复
热议问题