Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error caught at messaging().getToken() #1849

Closed
6 of 31 tasks
akhila-ariyachandra opened this issue Jan 22, 2019 · 7 comments
Closed
6 of 31 tasks

Error caught at messaging().getToken() #1849

akhila-ariyachandra opened this issue Jan 22, 2019 · 7 comments

Comments

@akhila-ariyachandra
Copy link

Issue


The firebase.messaging().getToken() works in most devices I've tested expect a Huawei Nova 3i. When I run the firebase.messaging().getToken() method inside a try block, an error get caught. The error object reads Error: AUTHENTICATION_FAILED. On inspecting the properties of the Error object I get

{
  framesToPop: 1,
  code: messaging/fcm-token-error
}

Using the following code to inspect the error,

console.log('error', error);
for (const field in error) {
    console.log(field, error[field]);
}

gives this
image

Project Files

iOS

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
# N/A

AppDelegate.m:

// N/A

Android

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->

Environment

  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • If known, the version of the platform are you experiencing the issue on:
    • ADD_SOMETHING_HERE e.g. iOS 10 or Android API 28
  • Operating System:
    • MacOS, version: N/A
    • Windows, version: N/A
    • Other, please specify: N/A
  • Build Tools:
    • ADD_SOMETHING_HERE e.g. Xcode 10, Android Studio 3.2
  • React Native version:
    • 0.57.8
  • React Native Firebase library version:
    • 5.2.0
  • Firebase module(s) you're using that has the issue:
    • N/A
    • Authentication
    • Analytics
    • Cloud Firestore
    • Cloud Messaging (FCM)
    • Crashlytics
    • Dynamic Links
    • Functions Callable
    • Invites
    • Instance ID
    • Notifications
    • Performance Monitoring
    • Realtime Database
    • Remote Config
    • Storage
  • Are you using TypeScript?
    • No
    • Yes, version: N/A
  • Are you using Expo, e.g. ExpoKit?
    • No
    • Yes, I've not ejected
    • Yes, but I have ejected to ExpoKit
    • Yes, but I have ejected to vanilla React Native
    • Expo version: N/A

Think react-native-firebase is great? Please consider supporting the project with any of the below:

@akhila-ariyachandra akhila-ariyachandra changed the title 🔥 Error caught at messaging().getToken() (:fire:) Error caught at messaging().getToken() Jan 22, 2019
@akhila-ariyachandra akhila-ariyachandra changed the title (:fire:) Error caught at messaging().getToken() Error caught at messaging().getToken() Jan 22, 2019
@Mexxerio
Copy link

Mexxerio commented Jan 23, 2019

+1

getting the same error when trying to call firebase.messaging().getToken()

EDIT:
Turns out my emulator didn't have google play services installed and the one I tried before that had an older version. After I created a new emulator with API 28 with google play, it worked again.

@Salakar
Copy link
Member

Salakar commented Jan 23, 2019

Please see https://rnfirebase.io/docs/v5.x.x/troubleshooting/android#Google-Play-Services-related-issues and the sections following it on how to check for valid play services installation.

@Salakar Salakar closed this as completed Jan 23, 2019
@Shivendra30
Copy link

Shivendra30 commented Sep 6, 2019

I am still facing this issue while trying to call firebase.messaging().getToken()

Error: AUTHENTICATION_FAILED
    at createErrorFromErrorData (NativeModules.js:152)
    at NativeModules.js:104
    at MessageQueue.__invokeCallback (MessageQueue.js:442)
    at MessageQueue.js:127
    at MessageQueue.__guard (MessageQueue.js:343)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:126)
    at debuggerWorker.js:80
App.js:335 

According to the react-native-firebase documentation, I executed the following function to know the status of my emulator's play services version

async function checkPlayServicesBasicExample() {
  const utils = firebase.utils();

  const {
    isAvailable,
    hasResolution,
    isUserResolvableError,
  } = utils.playServicesAvailability;

  // all good and valid \o/
  if (isAvailable) return Promise.resolve();

  // if the user can resolve the issue i.e by updating play services
  // then call Google Play's own/default prompting functionality
  if (isUserResolvableError) {
    return utils.promptForPlayServices();
  }

  // call Google Play's own/default resolution functionality
  if (hasResolution) {
    return utils.resolutionForPlayServices();
  }

  // There's no way to resolve play services on this device
  // probably best to show a dialog / force crash the app
  return Promise.reject(
    new Error('Unable to find a valid play services version.')
  );
}

I got a positive result saying that the device has a valid play services installation. I am using an Android emulator with API 29 and Android 10 (Google API)

So far, I don't understand what the issue is

@Dimon70007
Copy link

Open AVD manager window in android studio and click "Wipe Data". It could helps a lot
image

@smismailalam
Copy link

I am also facing same issue in nova 7i also install play store and play services

@Dimon70007
Copy link

@smismailalam Hi. Have you managed to get notifications to work on your huawei device?

@AliAbdelfattah
Copy link

I had the AUTHENTICATION_FAILED error on a Genymotion device after having installed Open GApps. I just needed to open the Play Store app and sign in, it worked right after that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants