In Expo's official document - Firebase SDK setup it is given that we need to store Firebase SDK. From some other articles I got to know that it should be stored in some javascript file. But now the question is how do I connect it with my App.js file or any app related file.
So for now I have just imported the file in the my App.js file but not using it in other pages. If I don't do this I receive an error saying "Firebase not initialized".
Should I add the SDK code in App.js file itself or is there any proper way to work with this ?
Related
I tried setting up Firebase Crashlytics to my React Native project.
I received the following error when I was building the project after I added the build phase script.
Script I added from the firebase guide (can be found here) :
Error:
MY-APP-ABC/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run:
No such file or directory
When I look in the folder of MY-APP-ABC, I don't see the SourcePackages folder anywhere.
If you installed firebase using cocoa pods use:
"${PODS_ROOT}/FirebaseCrashlytics/run"
If you installed firebase using Swift Package Manager use:
"${BUILD_DIR%/Build/*}/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run"
While using functionality of authentication through firebase, emulator is showing error i.e.{ you attempted to use a firebase module that is not installed on your android project by calling firebase.app() }.Please help me to resolve this error.
I'm using Expo as command line input.
react-native version -0.63.6,
"#react-native-firebase/app": "^8.4.3",
"#react-native-firebase/auth": "^9.2.3"
If you are using expo client, you should not use react-native-firebase modules because they are not compatible with expo client.
However, you can use firebase javascript SDK instead. It is all explained there.
Update 02-12-2021
Guys expo's eas-build is now public. You can add custom native codes and use react-native-firebase. Here is the link to a youtube tutorial. The video is short and super easy to follow. Here is the link to the docs
Previous answer
Currently, Firebase does not work in react native if you are using the mobile configuration. However, if you use the web configuration it will work. Here is the youtube tutorial. Watch from 38:20 to set up.
I downloaded sdk in the official way, but could not find the file.
My error:
Could not locate google-services.json or GoogleService-Info.plist files.
UnityEngine.Debug:LogWarning(Object)
Those files are specific to your project. You have to get one of those files from the Firebase console and add it to your project. You can follow the setup steps in the documentation.
I have 2 different projects that I'm working on concurrently. I worked on the 1st project and have a native index.js file for that project. Then, I wanted to write Cloud Functions' code for the 2nd project. So, when I typed 'firebase init functions', it is saying that there's a default project that's selected (even after typing "firebase use project-id"). How do I rectify this?
PS: I completed the whole sequence once and the index.js file got overwritten. Luckily for me, I had a back up for the 1st project.
Edit 2: I changed directories and created a project but it overwrote the index.js file once again in the 'functions' folder. How to fix this? Should I navigate out of the home directory itself?
Configure Multiple Projects
The Web and Admin SDKs are configured by directly passing values to
their initialization functions. For these SDK, you can use a runtime
check to select development or production configuration variables.
On your development machine / project build out each app under a unique folder.
I am not 100% sure to understand the problem but here are two possible scenarios:
1/ You are working in a specific project, writing Cloud Functions (i.e. modifying the index.js file) and you want to work on another totally different project. Just create a new directory (outside of the current project) and initialize a new project there, as explained in the doc here: "https://firebase.google.com/docs/cli/#initializing_a_project_directory"
2/ You are working in a specific project, writing Cloud Functions (i.e. modifying the index.js file) and you want to deploy the same code to another Firebase project. Just do firebase use <alias_or_project_id> as you have mentioned and then firebase deploy (or firebase deploy --only functions). Of course, in this scenario, you may need to adapt some other parts of your code when swapping from one project to the other, like for example the JavaScript config object.
If this answer does not answer your problem, please give some more details.
I'm trying to use the new Firestore DB into a brand new project with Vuejs, but I have errors with webpack.
I'm starting the project from scratch, with vue init webpack. However, although I can import and use the DB in a plain nodejs script (keyfile.json is not commited for security), I can't make it work in the Vuejs project.
Steps to reproduce (commited to Github for easy access)
Initialize a new project with vue init webpack
Copied the Firestore initializer
Imported it into main.js
Tried to reconfigure webpack, but errors appear (described in detail here)
Then I have errors in console, with the main page not rendering. I've tried to reconfigure webpack in two ways, but no success… :(
Can anyone help me in figuring out how to make Firestore work in a webpack Vuejs project?
Thanks a lot!