firestore is not working with React Native Expo - firebase

I installed firebase with react native expo using expo add firebase, then
I created a file (firebase.tsx) and added the Firebase configuration and initialized the app like in this screenshot with correct values].
I have added the google-services.json and
GoogleService-info.plist to the root of my expo project like the documentation say and i am importing firebase in my api service like this import Firebase from './../../../firebase'.
In my register function I call the firebase create user function
const response = await Firebase.auth().createUserWithEmailAndPassword(values.email.value, values.password.value)
The response is never returned, and if I use . then nothing happens either.
If I log firebase.auth I get an object with my API key and app name, etc. so Firebase is installed, but whenever I call the database for sign in or to access a collection nothing happens.
This is my package.json.
This is my app.json.
I added bundleIdentifier and googleServicesFile to iOS and package and googleServicesFile for Android.

currently Firebase seems not to be working in expo if you are using the android configuration. I have tried the web configuration and it has worked for me. Here is the youtube tutorial for it. Watch from 38:20 to set up.

Related

What benefit does linking Firebase web app to Firebase Hosting site brings?

What for should I link the web app to the Firebase Hosting site in the console? What are the benefits and effects?
The difference between the two is covered here: Whats the difference between firebase web app and firebase hosting.
The linking is mentioned in the documentation https://firebase.google.com/docs/web/setup#register-app, but the rationale and consequences are not explained.
The Firebase support documentation says:
You may need to link your web app to your Hosting site in the Project settings if you chose not to set up Hosting when you registered your web app with your Firebase project.
If you're using Firebase Hosting for your web app, you can use the reserved Hosting URLs to add Firebase SDKs and manage your Firebase configuration for your app.
In short, if you're using those special Hosting URLs that begin with __, in particular, /__/firebase/init.json, it helps to have linked your app to Hosting so that the configuration is complete. By my recollection, the config will then have a correct FCM config in this case.
You can configure partial import of the Firebase JavaScript SDK and only load the Firebase products that you need. If you're using a bundler (like Browserify or webpack), you can import individual Firebase products when you need them.
Note: You can use this option even if you use Firebase Hosting, but make sure to add your Firebase config object before initializing Firebase.
Install the Firebase JavaScript SDK:
a. If you don't already have a package.json file, create one by running the following command from the root of your JavaScript project:
npm init
b. Install the firebase npm package and save it to your package.json file by running:
npm install --save firebase
To include only specific Firebase products (like Authentication and Cloud Firestore), import Firebase modules:
// Firebase App (the core Firebase SDK) is always required and must be
listed first
import firebase from "firebase/app";
// If you are using v7 or any earlier version of the JS SDK, you should
import firebase using namespace import
// import * as firebase from "firebase/app"
// If you enabled Analytics in your project, add the Firebase SDK for
Analytics
import "firebase/analytics";
// Add the Firebase products that you want to use
import "firebase/auth";
import "firebase/firestore";
Initialize Firebase in your app:
// TODO: Replace the following with your app's Firebase project
configuration
// For Firebase JavaScript SDK v7.20.0 and later, measurementId is an
optional field
const firebaseConfig = {
// ...
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);

Firebase and Google Analytics - missing measurementId?

I have a few Firebase projects on which I use Firestore and Firebase Storage.
I want to start using Google Analytics and I see this page with all the instructions. The key setting being the parameter "measurementId".
So, following the instructions, I go to my project settings and find the config snippet but unlike in the instructions it does NOT contain this parameter...
How do I generate it?
The solution came from Firebase support, my project needed to be "relinked" to Google Analytics.
Relink your Firebase project to a Mobile App property
If you had
previously linked your Firebase project with your Analytics account
but are no longer able to locate your Firebase project in Analytics:
Open your Firebase project.
Open Project settings > Integrations.
Click the Analytics card to link Analytics to your project.
More details here
I experienced this also. It seems there is a bug in the website. Set up Firebase CLI and run the following command.
firebase --project <project-name> apps:sdkconfig
It should output something like the following:
? Select the app to get the configuration data: Web - 1:686396208177:web:5119a766dc890b7d671110 (WEB)
✔ Downloading configuration data of your Firebase WEB app
// Copy and paste this into your JavaScript code to initialize the Firebase SDK.
// You will also need to load the Firebase SDK.
// See https://firebase.google.com/docs/web/setup for more details.
firebase.initializeApp({
// ... snip ...
"measurementId": "redacted"
});
It includes measurementId.

FirebaseError: Analytics: "measurementId" field is empty in Firebase config

I cannot start project with yarn run dev and have this error:
FirebaseError: Analytics: "measurementId" field is empty in Firebase config. Firebase Analytics requires this field to contain a valid measurement ID. (analytics/no-ga-id).
I deleted yarn.lock file, added some extra variables to.env file. Where can I find measurementId? What might help in this kind of error? May be somebody have already faced with such problem. Thanks :)
This has nothing to do with your yarn lock file. Which client side sdk are you using for Firebase? Angularfire perhaps?
I assume you did put your firebase config in your environment file of your angular app. Just add the property "measurementId" to it with the correct value, and you are good to go. You can get this property in your Firebase project.
If your app uses the Firebase hosting and uses reserved URLs you are good to go since it automatically handles the configuration for your application. It seems it isn't your case.
You should add or update the config file to ensure the measurementId field is present. To find the config file go to Your apps card in your Project settings from the Firebase Console.
It can be useful as well: How to get the measurementId from the Firebase config?

Implementing Firebase Crashlytics in React native application - Android

I want to add Firebase Crashlytics to my React native project. I had a look online and some of the links suggested using Crashlytics with Fabric,
When I looked at Fabric and at somepoint it was mentioned that it was only available till 2020 and recommended to use Firebase Crashlytics. I am a bit confused.
Can any one suggest any link/guide to implement Firebase Crashlytics in my React native project.
Thanks
R
Its kind of simple.
First you need to add firebase to your project use the following link to link react-native-firebase .
https://rnfirebase.io/docs/v5.x.x/installation/initial-setup
Then use there doc to add firebase crash analytics into your code
https://rnfirebase.io/docs/v5.x.x/crashlytics/reference/crashlytics
for example:
import firebase from 'react-native-firebase'
componentDidMount(){
firebase.crashlytics().log('Test Message!');
firebase.crashlytics().recordError(37,"Test Error");
}
Add firebase to your project followed by crashlytics sdk. You might need to put the keys in your android and ios projects. Thts it.
Also have a look at sentry- its more suitable for JS based apps as it shows the line nos and the code which caused the crash. Crashlytics on the other hand as i remember shows only native crashes.

React-Native Firebase custom events not showing in DebugView mode on iOS

So I followed all the instructions, installed the library and linked it with react-native link react-native-firebase
Added the correct code in my AppDelegate.m with my GoogleService-Info.plist file added in my XCode project.
I also added -FIRAnalyticsDebugEnabled and -FIRDebugEnabled in the Arguments Passed On Launch like the documentation said.
Events like: user_engagement and first_open are showing correctly so I'm guessing that my config is OK, but my custom events aren't showing at all in the DebugView.
In React-Native-Firebase documentation it says
The default app is pre-initialized natively therefore there is no need to call initializeApp for the default app instance.
But in this example that I tried to follow, he uses initializeApp with for parameter debug: false so that events show up.
Code that I tried:
import RNFirebase from 'react-native-firebase';
const firebaseApp = RNFirebase.initializeApp({ debug: false });
firebaseApp.analytics().logEvent("test_event");
I did the same thing and it's not working at all. What is the correct syntax to send events on DebugView? I'm a little lost here. Thanks!
I'm using RN: 0.52.0

Resources