Xcode16.1&iOS18.1.1 Debugging App, unable to respond “didRegisterForRemoteNotificationsWithDeviceToken” delegation

I am an iOS development engineer. Recently, I updated the Xcode version to 16.1 (16B40) and updated my debugging device (iPhone 15) to iOS 18.1.1. However, I found that I could not respond to the delegate method.

I confirmed that my code, certificate, Xcode settings, and network environment had not changed. Simply executing

application.registerForRemoteNotifications()

in

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

did not receive a response(didRegisterForRemoteNotificationsWithDeviceToken or didFailToRegisterForRemoteNotificationsWithError ).

In the same environment, when I switched to another device for debugging (iOS 17.0.3), the delegate method would respond.

I really don't know what to do, I hope someone can help me, I would be very grateful.

Please note: Everything is normal when using devices before iOS 18.1.1 version

Perhaps you can tell me what options or settings affect this issue

Accepted Answer

This issue usually occurs due to:

1- device cannot have a persistent connection to APNs. Either due to security/proxies, etc., or being on an unreliable network. But you say another device in the same environment is OK, so perhaps this isn't it

2- a 3rd party push notifications SDK could be intercepting these callbacks. But if the same app is working on another device, then it is not that either. Unless you are building for each device separately, and there is a configuration mistake in the project based on your target iOS version or something.

Although a stretch, perhaps some system event have caused the device to get into a state that is causing this. try the following:

  1. Delete the app
  2. Put the device in Airplane Mode.
  3. After a few seconds, take it out of Airplane Mode. This will cause the device to try to reestablish its persistent connection to APNs.
  4. Install the app and try again.

If the problem persists, we may need to look at some diagnostic logs from that device.

I have very similar problem: some users of our app (all on iOS 18.1.1, but device models are different) are not able to register for push notifications. It can be due to bad network, of course, and I tried to simulate this situation (but only had luck on simulator), so here is my experience:

  • If application is offline while calling registerForRemoteNotifications and 3-5 minutes afterwards, appDelegate would never receive didRegisterForRemoteNotificationsWithDeviceToken or didFailToRegisterForRemoteNotificationsWithError.

I have a feeling that that may be the case for affected users. What would be best approach in this case? On simulator, I tried to call registerForRemoteNotifications but that never trigger didRegisterForRemoteNotificationsWithDeviceToken. However, on device registerForRemoteNotifications always matches didRegisterForRemoteNotificationsWithDeviceToken

For people affected: please check notes from https://developer.apple.com/forums/thread/799635 regarding following:

For a push token to be useful, the app has to either of:

  • be authorized to show notifications for visible notifications
  • be able to process the notifications in the background for silent notifications
Xcode16.1&iOS18.1.1 Debugging App, unable to respond “didRegisterForRemoteNotificationsWithDeviceToken” delegation
 
 
Q