I am getting this error after installing in iphone.
-
2@vishakh369 Please stop making edit suggestions just adding nonsense. They are most probably all getting rejected and you will be edit banned. – Benjamin W. May 25 '16 at 17:14
9 Answers
Using Xcode8, the fix was to simply enable Keychain Sharing in Capabilities
Open the app.xcworkspace file, select Target > Capabilities > Enable 'Keychain sharing'

- 289
- 3
- 2
-
4Could you clarify why we have enable this feature ? I did as above but it still not get FCM token. – Suke Nov 01 '16 at 02:56
-
-
This was a fix when you have no Entitlements file, because the APNS Capability alone wouldn't generate an Entitlements file, causing the app to not register with APNS. I believe this has since been fixed, but regardless, if you have a manual Entitlements file, or other capabilities that generate one, this will not change anything. – Tim Jan 31 '17 at 03:47
Possible reasons for this issue:
- Device date was not set to the current date.
- Bundle ID is not same that one you set in GoogleService-Info.
- .p12 certificate uploaded on Firebase Console is not correct.

- 2,410
- 3
- 19
- 30
-
8"1. Device date was not set to the current date." a very important and interesting point. You saved me some time! Thanks! Anyhow, does anyone know why it doesn't work if the device date is not set to the current date? – vbgd Dec 06 '16 at 10:22
-
If the device date is not correct, then Firebase can't figure out when to fetch the device token next, as you know Firebase keep on trying to fetch tokens at a regular interval. – Rachit Rawat Dec 06 '16 at 11:06
-
1
-
Device date means date on your iPhone. You can change it via Settings. @KrutarthPatel – Rachit Rawat Dec 30 '16 at 12:11
-
1@RachitRawat thanks bro.i am getting red mark add push notification entiliment to app id. – Krutarth Patel Dec 30 '16 at 12:16
-
Anytime bro. Just upvote the answer instead of thanking me, since it took me years to figure out the solution for this issue. @KrutarthPatel – Rachit Rawat Dec 30 '16 at 12:22
-
1@RachitRawat red mark error sometime come and go.can you guide? – Krutarth Patel Dec 30 '16 at 12:35
-
@KrutarthPatel Can you be more specific? What's the error line it's showing? – Rachit Rawat Jan 04 '17 at 05:58
-
1
-
3
-
1P12 Certificate for me was for development rather than distribution, thanks. – Ethan Humphries Jun 20 '17 at 12:05
Make sure that:
- Bundle ID is the same that one you set in GoogleService-Info
- Code signing params (Target => Build Settings => Code signing) are corrects and match with p12 cert file you've set in Firebase.
Also, you have to follow those tutos:
- Notification: https://firebase.google.com/docs/notifications/ios/console-audience
- Configuration: https://firebase.google.com/docs/ios/setup
And don't forget to ask permission to user simply to add that in your app (In AppDelegate file, or in other ViewController for example):
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()

- 4,730
- 1
- 41
- 39
-
4
-
Best not to add that "in AppDelegate file for example", as no one will accept the push notifications permission on the first app start. – Iulian Onofrei Nov 21 '16 at 16:20
i have same issue failed to fetch default token error domain=com.firebase.iid code=501 today spend 4 hours on this and finally got issue and thats my iphone time is wrong (manually i set diff time for testing)
so once check time when you have request firebase token.

- 539
- 2
- 7
- 18
Make sure you uploaded Development APNs certificate to Firebase. Go to Settings of your project => CLOUD MESSAGING tab.

- 2,265
- 5
- 28
- 44
Have been stuck for a while with this, for me the reason why I could not make it work was that I was using a secondary firebase app. It looks like a bug to me. As a workaround, I had to initialize the additional app before the default app (in AppDelegate.m):
//initialise the secondary app, for example:
NSString *logFirebaseOptionFile = [[NSBundle mainBundle] pathForResource:@"GoogleService-LOG-Info" ofType:@"plist"];
FIROptions *firebaseOptions = [[FIROptions alloc] initWithContentsOfFile:logFirebaseOptionFile];
NSString *logAppName = @"mybands_logs";
[FIRApp configureWithName:logAppName options:firebaseOptions];
//then the default app for FCM to work
[FIRApp configure];

- 93
- 1
- 9
Well, I also got this same problem. Can't fix it using solutions introduced by other posts. It seems that the communication between your client App FCM SDK and the FCM server goes wrong.
My fix was I loginned to my VPN (mainland China can't use google service if you don't do this). Then I could get the firebase token.
Besides, if you failed to get the token. Next time you try to access the firebase token using [[FIRInstanceID instanceID] token]. Firebase SDK will try to fetch the token again if it's still nil, and if this attempt succeeds, the token refresh notification (kFIRInstanceIDTokenRefreshNotification) will be posted.

- 273
- 3
- 9
You have to fix this line before handling this error:
Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"

- 1
- 1

- 255
- 1
- 3
-
While it's always good to link back to another SO answer, please always include the full answer in the one you also provide the link. -1 – Tim Nov 10 '16 at 05:07
Go to Signing & Capabilities
And Add Push Notification Capability

- 1,809
- 13
- 19