Which method will be triggered when the notification received on iPhone(not after the notification is tapped and opened)?

后端 未结 4 1088
遇见更好的自我
遇见更好的自我 2021-01-16 05:41

I’m now using didReceiveRemoteNotification to get the payload of the notification pushed from Parse, however, it is only triggered when the notification is tapp

4条回答
  •  滥情空心
    2021-01-16 06:06

    Below method is invoked when a remote notification is received in iOS.

    func application(_ application: UIApplication,
                     didReceiveRemoteNotification userInfo: [AnyHashable : Any],
                     fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        // do something
    }
    

    Apart from basic setup for remote notifications you should set below flag in payload of notification.

    "content-available": 1
    

提交回复
热议问题