【问题标题】:react native android, got FIS_AUTH_ERROR when trying to get firebase messaging device token反应原生android,在尝试获取firebase消息设备令牌时得到FIS_AUTH_ERROR
【发布时间】:2020-11-07 09:51:56
【问题描述】:

我尝试使用 react native base 消息传递和 react native 推送通知库来获取 android 设备令牌以发送推送通知:

我在 AndroidManifest.xml 中添加了配置:

...
   <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

    <!-- < Only if you are using GCM or localNotificationSchedule() > -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <permission
        android:name="${applicationId}.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
    <!-- < Only if you are using GCM or localNotificationSchedule() > -->
...

在我的 App.js 中

// ----- COMPONENT DID MOUNT ---- //
  async componentDidMount() {
    // ====================================================== //
    // ====================================================== //
    // ====================================================== //
    const granted = messaging().requestPermission();

    if (granted) {
      console.log('User granted messaging permissions!');
      // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
      firebase
        .messaging()
        .getToken()
        .then((fcmToken) => {
          if (fcmToken) {
            // user has a device token
            console.log('-------- FCM TOKEN -------');
            console.log(fcmToken);
            console.log(JSON.stringify(fcmToken));
            this._setItem(fcmToken);
          } else {
            // user doesn't have a device token yet
            console.log('error');
          }
        });
      // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
    } else {
      console.log('User declined messaging permissions :(');
    }
    // ====================================================== //
    // ====================================================== //
    // ====================================================== //
  }
  // ----- FIN COMPONENT DID MOUNT ---- //

我明白了:

可能的未处理承诺拒绝(id:0):

错误:[消息/未知] FIS_AUTH_ERROR

NativeFirebaseError:[消息/未知] FIS_AUTH_ERROR

【问题讨论】:

  • 我也面临同样的问题。你能分享一下你是怎么解决的吗?

标签: android react-native push-notification firebase-cloud-messaging token


【解决方案1】:

我通过再次下载 google-services.json 文件并将其替换为我拥有的旧文件来修复它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-13
    • 2014-01-21
    • 1970-01-01
    • 1970-01-01
    • 2016-05-25
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多