Neither didRegisterForRemoteNotificationsWithDeviceToken, nor didFailToRegisterForRemoteNotificationsWithError gets called. There is a message in logs "Registered for push notifications with token: <...>", which probably means registration itself succeeds. Push notifications capability is added, certificates are in place, I am testing on device, not sim, but AppDelegate's methods for pushes are just not called. didFinishLaunchingWithOptions is called normally btw, which means my UIApplicationDelegateAdaptor is ok. I am using xcode Version 13.2.1 and ios 15.2.
Here is how I subscribe to pushes:
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, _) in
NSLog("PUSH NOTIFICATION PERMISSION GRANTED: \(granted)")
guard granted else { return }
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
Here are method signatures:
func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) { }
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { }
I need to receive device token to send to server, please help