0

On iOS 10, didReceiveRemoteNotification method not getting fired when the user launch the app by tapping on push notification. How to fix this?

Nikita Khandelwal
  • 1,741
  • 16
  • 25

1 Answers1

1

i think you need to do for ios 10.0

import UserNotifications
   // didFinishLaunchingWithOptions method
 if #available(iOS 10.0, *) {
        let center = UNUserNotificationCenter.currentNotificationCenter()
        center.delegate = self
        center.requestAuthorizationWithOptions([.Alert, .Sound, .Badge], completionHandler: { (granted, error) in
            // do nothing for now
        })
    }

Add extension

extension AppDelegate: UNUserNotificationCenterDelegate {

@available(iOS 10.0, *)
func userNotificationCenter(center: UNUserNotificationCenter, didReceiveNotificationResponse response: UNNotificationResponse, withCompletionHandler completionHandler: () -> Void) {
    // When app is killed and or in background tapping on this will resut this event
    let payload = Payload(dict: response.notification.request.content.userInfo)
    triggerThePaylod(payload)
}

}

i hope it will help you

jignesh Vadadoriya
  • 3,244
  • 3
  • 18
  • 29