Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement and test Firebase Analytics in a React-Native project?

I have learned from reading that Firebase officially supports react-native.

https://firebase.googleblog.com/2016/01/the-beginners-guide-to-react-native-and_84.html

I have followed the above link and performed these steps:

  1. npm install firebase --save
  2. Opened index.ios.js and imported firebase

import * as firebase from 'firebase';

  1. Initialise Firebase

const firebaseConfig = {
  apiKey: "<your-api-key>",
  authDomain: "<your-auth-domain>",
  databaseURL: "<your-database-url>",
  storageBucket: "<your-storage-bucket>",
  ,
};
const firebaseApp = firebase.initializeApp(firebaseConfig);

I have put all the right values in the above fields. From my understanding, this should enable Firebase analytics in my project and I should see session reporting in Firebase console. But I can't see anything.

Am I missing anything here? Also is there any way to get Firebase logs in react native so that I can know what's happening?

like image 598
Rohit Goyal Avatar asked Oct 18 '22 22:10

Rohit Goyal


1 Answers

The Firebase web SDK (including real-time database) works with React Native. However, Firebase does not currently offer analytics as part of the Web SDK. To enable analytics, you would need to implement a wrapper around the native SDKs or use a library such as https://github.com/fullstackreact/react-native-firestack.

like image 68
Sat Mandir Khalsa Avatar answered Oct 21 '22 07:10

Sat Mandir Khalsa