firebase: can't find variable IDBIndex

Viewed 8938

I'm developing an app with react-native (v0.60) and I need push notifications. I decided to use firebase as service but I have an error during initialisation.

Code:

import {AppRegistry} from 'react-native';
import Config from 'react-native-config'
import * as firebase from 'firebase/app'
import '@firebase/messaging'

import firebaseConfig from 'App/src/firebase.config'
import App from './App';
import {name as appName} from './app.json';

firebase.initializeApp(firebaseConfig)
const messaging = firebase.messaging()
messaging.usePublicVapidKey(Config.FIREBASE_KEY_PAIR)

AppRegistry.registerComponent(appName, () => App);

The problem is that I get the error:

ReferenceError: Can't find variable: IDBIndex

How can I fix this?

4 Answers

firebase only supports Authentication, Firestore & Realtime databases, Storage, and Functions on React Native. Other modules like Analytics are not supported through the Firebase JS SDK, but you can use expo-firebase-analytics for that. If you'd like access to the full suite of native firebase tools

please remove firebase.analytics();

It's because you have enabled Google Analytics for your app. Disable Analytics from the Firebase settings and again copy the Firebase file data from Firebase and replace it with the old firebase.js file in the project.

I would advise to use the React Native Firebase wrapper instead. As they say:

Although some features from the Firebase Web SDK will generally work with React Native, it is mainly built for the web and as such has a limited compatible feature set. In contrast we use the Firebase Native SDKs - this allows us to provide APIs to a vast majority of Firebase products and services.

please remove firebase.analytics(); form where ?

Related