why didRegisterForRemoteNotificationsWithDeviceToken is not called

I had the same issue: calling registerForRemoteNotificationTypes: invoked neither application:didRegisterForRemoteNotificationsWithDeviceToken: nor application:didFailToRegisterForRemoteNotificationsWithError:

I eventually resolved this issue with the help of Apple’s technical note TN2265.

This is what I did:

First off, I double-checked that I am indeed registering correctly for Push Notifications, including verifying my provisioning profile for “aps-environment” key and the codesigning of the .app file itself. I had it all set up correctly.

I then had to debug Push Notification status messages in the console (you need to install PersistentConnectionLogging.mobileconfig provisioning profile on your device and reboot it. See TN2265 under “Observing Push Status Messages”). I noticed that apns process starts a timer and calculates a minimum fire date, which made me suspect that the Push-Notification registration confirmation message, which is normally presented at this point, is supressed by APNS, as indicated in TN2265:

Resetting the Push Notifications Permissions Alert on iOS

The first time a push-enabled app registers for push notifications, iOS asks the user if they wish to receive notifications for that app. Once the user has responded to this alert it is not presented again unless the device is restored or the app has been uninstalled for at least a day.

If you want to simulate a first-time run of your app, you can leave the app uninstalled for a day. You can achieve the latter without actually waiting a day by setting the system clock forward a day or more, turning the device off completely, then turning the device back on.

So, I removed the app from the device, then manually changed the iPhone’s date in Settings, rebooted the device, and re-installed the app.

The next time my code called registerForRemoteNotificationTypes, it received callbacks as expected.

This resolved the issue for me. Hope it helps.

Leave a Comment