Useful or not, from you.
react-native-firebase Error caught at messaging().getToken()

<!--- Hello there you awesome person; Please note that the issue list of this repo is exclusively for bug reports;

  1. For feature requests please visit our Feature Request Board.
  2. For questions and support please use our Discord chat: https://discord.gg/C9aK28N or Stack Overflow: https://stackoverflow.com/questions/tagged/react-native-firebase
  3. If this is a setup issue then please make sure you've correctly followed the setup guides, most setup issues such as 'duplicate dex files', 'default app has not been initialized' etc are all down to an incorrect setup as the guides haven't been correctly followed. -->

<!-- NOTE: You can change any of the [ ] to [x] to mark an option(s) as selected -->

<!-- PLEASE DO NOT REMOVE ANY SECTIONS FROM THIS ISSUE TEMPLATE --> <!-- Leave them as they are even if they're irrelevant to your issue -->

Issue

<!-- Please describe your issue here --^ and provide as much detail as you can. --> <!-- Include code snippets that show your usages of the library in the context of your project. --> <!-- Snippets that also show how and where the library is imported in JS are useful to debug issues relating to importing or methods not found issues -->


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

<!-- Provide the contents of key project files which will help to debug --> <!-- For Example: --> <!-- - iOS: Podfile contents. --> <!-- - Android: android/build.gradle contents. --> <!-- - Android: android/app/build.gradle contents. --> <!-- - Android: AndroidManifest.xml contents. -->

<!-- ADD THE CONTENTS OF THE FILES IN THE PROVIDED CODE BLOCKS BELOW -->

iOS

ios/Podfile:

  • [ ] I'm not using Pods
  • [x] 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

<!-- change [ ] to [x] to select an option(s) -->

  • Platform that you're experiencing the issue on:
    • [ ] iOS
    • [x] 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
    • [x] 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
    • [x] Cloud Messaging (FCM)
    • [ ] Crashlytics
    • [ ] Dynamic Links
    • [ ] Functions Callable
    • [ ] Invites
    • [ ] Instance ID
    • [ ] Notifications
    • [ ] Performance Monitoring
    • [ ] Realtime Database
    • [ ] Remote Config
    • [ ] Storage
  • Are you using TypeScript?
    • [x] No
    • [ ] Yes, version: N/A
  • Are you using Expo, e.g. ExpoKit?
    • [x] 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

<!-- Thanks for reading this far down ❤️ --> <!-- High quality, detailed issues are much easier and quicker to triage for maintainers -->

<!-- For bonus points, if you put a 🔥 (:fire:) emojii at the start of the issue title we'll know --> <!-- that you took the time to fill this out correctly, or, at least read this far -->


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

That's a useful answer
Without any help

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