【问题标题】:Issue - My React Native App showing FirebaseError: Messaging问题 - 我的 React Native 应用程序显示 FirebaseError: Messaging
【发布时间】:2021-10-02 08:46:44
【问题描述】:

当我尝试通过调用 firebase.messaging() 在我的 react 本机应用程序中使用 firebase 云消息传递时,我目前收到以下错误:

FirebaseError:消息:此浏览器不支持使用 firebase SDK 所需的 API。 (消息/不支持的浏览器)。

我不太清楚为什么在尝试使用 iOS 推送通知而不是 Web 通知时出现浏览器错误。我不确定我是否在我的 firebase 控制台中设置了 firebase 云消息传递,或者是否需要。我查看了一些链接,但它们没有帮助。

尝试在我的应用上发送消息时,我使用的是真正的 iOS 设备。

以下是我的 Firebase 配置:

import firebase from '@react-native-firebase/app';


const firebaseConfig = {
  apiKey: "AIzaSyCjWwL5rs6n-lTlqAkaEh5eK**********",
  authDomain: "appname***-36a**.firebaseapp.com",
  databaseURL: "https://appname***-36a**.firebaseio.com",
  projectId: "appname***-36a**",
  storageBucket: "appname***-36a**.appspot.com",
  messagingSenderId: "898189283****",
  appId: "1:898189283761:web:9e09a6566fcb0629d*****",
  measurementId: "G-VYF6PH0M**"
};



export default firebase;

我希望最终获得 FCM 注册令牌。有人可以帮忙吗?我正在使用裸反应本机。

【问题讨论】:

    标签: ios firebase react-native push-notification firebase-cloud-messaging


    【解决方案1】:

    您必须使用此库中的消息传递。

    “@react-native-firebase/messaging”

    import messaging from '@react-native-firebase/messaging';
    

    更多参考这里是官方文档https://rnfirebase.io/messaging/usage

    【讨论】:

    • 谢谢,但在构建时安装“@react-native-firebase/messaging”会给我错误“未定义符号:_OBJC_CLASS_$_FIRAuth”
    • 你安装了 pod 吗?
    • 是的。我运行命令“npm i @react-native-firebase/messaging”,然后运行命令“cd ios/ && pod install”
    • @react-native-firebase/app 使用这个库而不是这个 import firebase from 'firebase/app';
    • 好的,所以我收到错误“ERROR FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app)。”按照链接rnfirebase.io 中的步骤安装@react-native-firebase/app。
    猜你喜欢
    • 2021-01-28
    • 1970-01-01
    • 1970-01-01
    • 2021-03-27
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    • 2022-11-23
    • 2020-01-08
    相关资源
    最近更新 更多