36

enter image description here

I am getting this error after installing in iphone.

Rishabh
  • 3,752
  • 4
  • 47
  • 74
  • 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 Answers9

28

Using Xcode8, the fix was to simply enable Keychain Sharing in Capabilities

Open the app.xcworkspace file, select Target > Capabilities > Enable 'Keychain sharing'

yoziru_desu
  • 289
  • 3
  • 2
  • 4
    Could 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
  • Why does this capability is required? – B 7 Dec 13 '16 at 09:16
  • 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
27

Possible reasons for this issue:

  1. Device date was not set to the current date.
  2. Bundle ID is not same that one you set in GoogleService-Info.
  3. .p12 certificate uploaded on Firebase Console is not correct.
Rachit Rawat
  • 2,410
  • 3
  • 19
  • 30
11

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. enter image description here

Also, you have to follow those tutos:

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()
Phil
  • 4,730
  • 1
  • 41
  • 39
4

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.

HiteshGs
  • 539
  • 2
  • 7
  • 18
1

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

Leap Bun
  • 2,265
  • 5
  • 28
  • 44
1

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];
eussam
  • 93
  • 1
  • 9
1

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.

Jiang Wang
  • 273
  • 3
  • 9
0

You have to fix this line before handling this error:

Failed to fetch default token Error Domain=com.firebase.iid Code=0 "(null)"

Here is an answer to fix this issue

Community
  • 1
  • 1
starlord_amj
  • 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
0

Go to Signing & Capabilities And Add Push Notification Capability

Guru Prasad mohapatra
  • 1,809
  • 13
  • 19