How to fix Failed to fetch default token error?

后端 未结 8 2026
无人及你
无人及你 2020-12-01 09:23

\"enter

I am getting this error after installing in iphone.

相关标签:
8条回答
  • 2020-12-01 09:33

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

    0 讨论(0)
  • 2020-12-01 09:36

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

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

    0 讨论(0)
  • 2020-12-01 09:45

    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.

    0 讨论(0)
  • 2020-12-01 09:46

    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];
    
    0 讨论(0)
  • 2020-12-01 09:47

    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()
    
    0 讨论(0)
  • 2020-12-01 09:55

    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.

    0 讨论(0)
提交回复
热议问题