1

I was wondering which delegate function, we should use in swift 3.0 instead of :

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)

for handling notifications, when received as this delegate function is deprecated. I checked this link as well: UILocalNotification is deprecated in iOS10 but didn't find receiving delegate. If I Use same delegate function, the delegate isn't is getting called.

Thanks.

UGandhi
  • 518
  • 1
  • 8
  • 28

1 Answers1

3

I think there is a misunderstanding with your case UILocalNotification is deprecated so far (as you already mentioned "UILocalNotification is deprecated in iOS10" in your question) and that's what are you asking about:

UILocalNotification receiving function deprecated in iOS10 (Swift 3.0)

But method: userNotificationCenter(_:didReceive:withCompletionHandler:) has nothing to do with UILocalNotification, instead, it is related to the UserNotifications Framework, which does supports iOS 10 -as mentioned in its documentation-:

enter image description here

So basically, you should go UserNotification instead of -deprecated- UILocalNotification, therefore:

func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)

should work as expected with iOS 10.

Ahmad F
  • 30,560
  • 17
  • 97
  • 143