1

As I updated all the Notification methods in my AppDelegate Class. PushNotification are receiving when the app is open and in close mode. I facing the issue when my app is closed and I received notification and try to tap the notification, It opens the app screen however these lines of code are not called:

let remoteNotification: NSDictionary! = launchOptions?[UIApplicationLaunchOptionsRemoteNotificationKey] as? NSDictionary
        print("remoteNotification = \(remoteNotification)")
        if (remoteNotification != nil) {
            print("***************************************\n\n\n\n\n launchOptions = \(launchOptions)\n ***************************************\n\n\n\n\n")

         self.notificationHandlingFunction(remoteNotification)
        }

and when I want to see the logs it will not appearing in the Log list:

enter image description here

My device is attached with Xcode but not running. In code I print RemoteNotification however it not showing when I search this keyword. I am facing this issue in Swift.

How can I manage my Notification method when this case arise.

Shobhakar Tiwari
  • 7,862
  • 4
  • 36
  • 71
Gourav Joshi
  • 2,419
  • 2
  • 27
  • 45
  • http://stackoverflow.com/questions/30297594/uiapplicationlaunchoptionsremotenotificationkey-not-getting-userinfo – Sachin Vas Oct 07 '16 at 08:32

1 Answers1

2

Go to project > Capabilities, Turn on Background Modes and enable Remote notifications

enter image description here

and then in app delegates simply add following method

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
        self.notificationHandlingFunction(remoteNotification)
}

will work for all cases

Zuhair Hussain
  • 823
  • 9
  • 19