TypeError(RN 0.61.2)(_ firebaseApp.default.messaging不是函数)

贵有恒,何必三更起、五更眠、最无益,只怕一日曝、十日寒。这篇文章主要讲述TypeError(RN 0.61.2):_ firebaseApp.default.messaging不是函数相关的知识,希望能为你提供帮助。
我将我的应用程序升级到react-native-0.61.2,所以我不得不将react-native-firebase升级到6.0.3,我从添加@react-native-firebase/app@react-native-firebase/messaging包开始。

import { Platform } from 'react-native' import { firebase } from '@react-native-firebase/messaging'// pluck values from your `GoogleService-Info.plist` you created on the firebase console const iosConfig = { clientId: '...', appId: '...', apiKey: '...', databaseURL: '...', storageBucket: '...', messagingSenderId: '...', projectId: '...', persistence: true, }// pluck values from your `google-services.json` file you created on the firebase console const androidConfig = { clientId: '...', appId: '...', apiKey: '...', databaseURL: '...', storageBucket: '...', messagingSenderId: '...', projectId: '...', persistence: true, }const firebaseApp = firebase.initializeApp( // use platform-specific firebase config Platform.OS === 'ios' ? iosConfig : androidConfig, // name of this app 'myApp' )export default firebaseApp

在我的档案上,我正在这样做
import firebaseApp from '...path to/firebaseApp' . . . async checkPermission() { console.warn('checkPermission firebaseApp : ', firebaseApp) const enabled = await firebaseApp.messaging().hasPermission() if (!enabled) { this.requestPermission() } this.syncToken() } . . .

我要下一个警告:
警告#1:
checkPermission firebaseApp :{"_40": 0, "_55": {"_automaticDataCollectionEnabled": false, "_deleteApp": [Function bound deleteApp], "_deleted": false, "_initialized": false, "_intialized": true, "_name": "...", "_nativeInitialized": false, "_options": {"apiKey": "...", "appId": "...", "clientId": "...", "databaseURL": "...", "debug": true, "messagingSenderId": "...", "projectId": "...", "storageBucket": "..."}}, "_65": 1, "_72": null}

警告#2:
Possible Unhandled Promise Rejection (id: 0): TypeError: _firebaseApp.default.messaging is not a function. (In '_firebaseApp.default.messaging()', '_firebaseApp.default.messaging' is undefined)

我做错什么了,有什么帮助吗?
谢谢大家。
答案我应该使用默认应用因此在initializeApp中,我删除了第二个选项myApp和此方法更改为
async checkPermission() { console.warn('checkPermission firebaseApp : ', firebaseApp) firebaseApp const enabled = await firebase.messaging().hasPermission() if (!enabled) { this.requestPermission() } this.syncToken() }

【TypeError(RN 0.61.2)(_ firebaseApp.default.messaging不是函数)】从'@ react-native-firebase / app'导入firebase导入'@ react-native-firebase / messaging'

    推荐阅读