[IOS] Debugging a production nightmare ;)

[IOS] Debugging a production nightmare ;)

For the past hours, I've been running in circles trying to tackle a sudden issue with our application in the Apple Store. Here's my account of this perplexing journey, filled with twists, turns, and a lot of head-scratching.

Initially, I speculated a few reasons for the breakdown:

  • Perhaps, the app's compatibility issues stemmed from operating in a legacy environment.
  • Maybe internal file writing within the app was getting corrupted.
  • Or, it was possible that the app wasn't requesting or processing permissions correctly, blocking file writing capabilities.

But none of these theories hit the mark.

Using the iOS emulator didn't shed any light either, as it ran without any hiccups, not replicating the errors our testers were continuously reporting.

As a last resort, I switched to testing on a real device, considering that sometimes apps behave differently on emulators versus actual devices. And soon enough, my console threw up the infamous FirebaseException error:

FirebaseException ([firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling `getAPNSToken()`.)

My initial fix was to dive into XCode and check a couple of things:

  • Were background modes and push notifications enabled?
    To my surprise, push notifications was missing. I quickly added them through the "Capability" section in "Signing and Certificates."

However, rerunning the app resulted in the same error, which was baffling, as everything seemed correctly configured.

My next step? Debugging the code that was supposed to retrieve the APNS token from Firebase. Here's where things got interesting – the token was returning as null. This pointed towards a potential issue with either iOS, Firebase, or a combination of both.

To give you a bit more background, Firebase Cloud Messaging (FCM) operates on a client-server model. The server handles message creation and targeting, and FCM sends these messages to iOS/Android apps. The registration process with FCM is three-fold: the client app sends credentials to FCM, receives a unique token, and then relays this token to its server.

So, I checked if the APN settings in the Firebase console were correctly configured – they were. The final step was to verify if the iOS app on the Apple portal had the necessary signing certificates and push notifications. Turns out, it didn't.

After setting up the required certificates and services, the moment of truth arrived. I ran the app, and voila – it worked flawlessly!

This experience reminded me of an article that was instrumental in navigating through the Firebase push notification settings for iOS. It's a valuable resource for anyone facing similar hurdles:


About Me

I am Zaahra, a Google Women Techmakers Ambassador who enjoy mentoring people and writing about technical contents that might help people in their developer journey. I also enjoy building stuffs to solve real life problems.

To reach me:

LinkedIn: https://www.linkedin.com/in/faatimah-iz-zaahra-m-0670881a1/

X (previously Twitter): _fz3hra

GitHub: https://github.com/fz3hra


Umme Faatimah-Iz-Zaahra Mujore | Google Women TechMakers Ambassador | Software Engineer