1

I'm having trouble with firebase notifications. I'm getting this error [Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)" which I guess leads to InstanceID.instanceID().token() being nil.

Things I've tried based on this and this, and this and this and this:

  1. Following the instructions in the 1st and 2nd links several times

  2. Enabling keychain sharing (actually was already enabled)

  3. Switching push notification capability off and on again

  4. Making sure bundle id is the same as the one in google's plist (although I used to change it back and forth)

  5. Adding distribution and development certificates to firebase console (.p12)

  6. Resorting to auth keys instead of certificates

  7. Adding an observer for the InstanceIDTokenRefresh key in app delegate

  8. Uninstall the app, clean, clean build folder, clean the derived data directory

  9. Setting APNS token in both these ways, one at a time and together

    InstanceID.instanceID().setAPNSToken(deviceToken, type: .unknown) Messaging.messaging().apnsToken = deviceToken

  10. Querying InstanceID.instanceID().token() immediately, and after a 25 ~ 50 seconds delay.

  11. Setting Messaging.messaging().delegate and implementing messaging(:didRefreshRegistrationToken:)

  12. Changing code signing identity values to these: enter image description here

And maybe other things too that I can't remember!!!

KENdi
  • 7,576
  • 2
  • 16
  • 31
Milad.Nozari
  • 2,243
  • 3
  • 26
  • 47

1 Answers1

1

This project was started with a different name and bundle ID (by another developer) and the keychain group set in the capabilities section was the old bundle ID. Although I had added the new bundle ID, the problem persisted until I deleted the old entry from the list of keychain groups! Or maybe I could've just change the value in the entitlement file.

EDIT: In a nutshell, the group in the capabilities screen should match the one in the entitlements file.

Milad.Nozari
  • 2,243
  • 3
  • 26
  • 47