Unable to obtain APNS token in xCode Swift after iOS 18 Upgrade

After upgrading to iOS 18, in my app development using xCode 16.0 (16A242d) and Swift, I am totally unable to obtain an APNS token from my own device using didRegisterForRemoteNotificationsWithDeviceToken

The delegate simply won’t fire.

I was able to do so repeatedly in the same app a week earlier, using iOS 17xx. That part of the code has not changed.

I just now restored my phone and installed a clean version of iOS 18, but the issue has not changed.

Have tried using WiFi and also cellular networks.

It is a no-go.

Answered by MSTACE in 807136022

It was the Firebase/Firestore Library!

In summary, the Firebase/Firestore functions are running asynchronously, totally destroying the timing of the APNS delegate functions. Turn Firebase/Firestore off, and APNS works again.

We will retrieve the APNS token before any Firebase/Firestore functions are engaged.

Typically this issue comes up if the device cannot connect to APNs. But you say you have tried different networks, so that is unlikely. But still do check if you have something on the device that might be interfering, perhaps a VPN app that needs reconfiguring after updating to iOS 18?

There is no reason to suspect iOS 18 as the culprit as this would have been a widespread issue.

This leaves something in your app code or configuration. As you have also changed Xcode, make sure something has not broken in your app settings, like the entitlement file is not being properly built, or somehow the aps-environment entitlement is still present in the build and says either development or production


Argun Tekant /  DTS Engineer / Core Technologies

I created a new xCode project to test the APNS. Simple code.

Here is my output. The token never arrives, whether on cellphone network of Google Fibre.

Is there any way Apple can check to see if my device is asking for the APNS token?

By the way, I never received any note from the Feedback Assistant case: FB15322637

Application did finish launching Requesting notification permission Notification permission granted Registering for remote notifications

Accepted Answer

It was the Firebase/Firestore Library!

In summary, the Firebase/Firestore functions are running asynchronously, totally destroying the timing of the APNS delegate functions. Turn Firebase/Firestore off, and APNS works again.

We will retrieve the APNS token before any Firebase/Firestore functions are engaged.

Firebase does some swizzling.

Read their documentation and see if setting the FirebaseAppDelegateProxyEnabled flag to false solves your issue.

Unable to obtain APNS token in xCode Swift after iOS 18 Upgrade
 
 
Q