0

I am implementing push kit and receiving remote notification in delegate method "didReceiveIncomingPushWithPayload" but notification center is not showing that message. I have checked in my device "Notification-> app" allow notification and show in notification center options are enabled.

Hasya
  • 9,792
  • 4
  • 31
  • 46

1 Answers1

1

If you are using below method.

func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) 

Then, pushkit helps in getting silent push notification, that remote notification would not come in notification center like simple APNS.

From this method when you receive remote notification with desired information now you have to schedule UILocalNotification which will come in notification center.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

       if let notification:UILocalNotification = launchOptions?[UIApplicationLaunchOptionsLocalNotificationKey] as? UILocalNotification {

       }
}

Even you can keep UILocalNotification object in NSUserDefault, So you can retrieve it in didFinishLaunchingWithOptions in case user device is getting restart and notification information is very crucial.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Hasya
  • 9,792
  • 4
  • 31
  • 46
  • thanks @Hasya, I am tapping any notification then In didFinishLaunchingWithOptions delegate method launchOptions dictionary is nil. So, couldn't detect which notification is tapped. – Pankaj Chauhan Sep 23 '16 at 05:58
  • If you are scheduling UILocalNotification from didReceiveIncomingPushWithPayload and when you tap on notification you must get it in didFinishLaunchingWithOptions. check my updated answer. – Hasya Sep 23 '16 at 06:20
  • got the solution,Thanks for your quick feedback @Hasya, when I am tapping notification then didReceiveLocalNotification delegate method is called. – Pankaj Chauhan Sep 23 '16 at 11:43
  • Welcome, if my answer is worth for you then kindly accept it. Have a happy coding. – Hasya Sep 23 '16 at 11:57