UNUserNotificationCenterDelegate didReceive response not getting called
I am seeing a weird issue where on click of notification(Foreground and Background state),
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void)
is not getting called.But what makes this even more weird is that the other UNUserNotificationCenterDelegate function is getting called when notification is received:
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
I am getting this following warning in the console
Warning: UNUserNotificationCenter delegate received call to -userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: but the completion handler was never called.
I do have delegate set properly.
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: { (granted, error) in
if granted {
let center = UNUserNotificationCenter.current()
center.delegate = self
}
})
Here is the implementation of didReceive method.
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
if response.actionIdentifier == UNNotificationDismissActionIdentifier {
print ("Message Closed")
}
else if response.actionIdentifier == UNNotificationDefaultActionIdentifier {
print ("App is Open")
}
completionHandler()
}
Please help me to solve this. Thanks.
iPhone 7, iOS 12