Host multiple projects to same firebase project - firebase

I have two different react apps - one admin app and another client app. The two apps share the same Firebase database and now I want to deploy both of them to Firebase hosting so that I can access them from two different URLs.
To do this I followed the following approach:
Type firebase init
Type firebase deploy
This works fine, but the issue is that when I deploy my second project it overwrites the URL for my first project.
I tried adding another project in the firebaserc file so that it looks like:
{
"projects": {
"default": "fire-app-9c444",
"project1": "fire-app-9c444-admin",
"project2": "fire-app-9c444-mobile"
}
}
running firebase use then lists the projects as
* default (fire-app-9c444)
project1 (fire-app-9c444-admin)
project2 (fire-app-9c444-mobile)
But I cannot change to project1 or project2. If I write firebase use project1 I get the following error:
Error: Unable to use alias project1, please verify project
fire-app-9c444-admin exists and you have access.
Any ideas how to go about this?

I had the same error. In my case my project1 app was created with a different Google account as my project2 app. I just added the other Google account as a maintainer in my Firebase project settings (https://console.firebase.google.com/project/${projectName}/settings/iam). Now I can switch projects with firebase use ${projectName}
With firebase login you can check which Google account you are currently logged in

Related

Setup Firebase Remote Config

I want to use Remote Config in a application Xamarin.Forms.
I use a blog - Firebase Remote Config in Xamarin Forms
I have a question about the section: Setup Firebase Remote Config.
Quote
We can setup Firebase Remote Config through the Firebase portal https://console.firebase.google.com/project/Your-Firebase-Project/config and it is an easy process because the portal GUI is nice and friendly. To do it, we add a new parameter key and the default value and of course it can be a json (the GUI has a tool to validate the format of the json content). In the example case the key will be Features and the default value a json:
{
"ShowPlayerDetail": false
}
In this case, we setup a key called ShowPlayerDetail to show or not the player detail.
Question:
Where is the JSON file referred to in this section?
Note.
I am currently in a project.
Update-1
Update-2
Update-3
Update-4
Update-5
I have completed the following steps.
Did I do the right thing?
Do my actions correspond to what is described in the blog?
Or do I need to perform Publish changes? (see Pic-4. Result)
Pic-1
Pic-2
Pic-3
Pic-4. Result
You're using an existing Firebase project but there are no apps in your project, please see the Update-4 screenshot .
You could click the iOS or Android icon to add app to your Firebase project, and make sure the Apple bundle ID matches the Bundle identifier in info.plist of your Xamarin.iOS project, the Android package name matches the packagename in AndroidManifest.xml of your Xamarin.Android project. After registering the app, you can download the google-services.json file for Android and the GoogleService-Info.plist file for iOS.

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?

Unable to change the default project to deploy my project on firebase hosting

i am trying to deploy my project on firebase hosting. And whenever i am using firebase init it is showing error in terminal as "firebaserc already has a default project " and it exit with that error
i have tried firebase logout and firebase login again . And used "firebase use" command also to change the project but it is still performing the firebase init action on the default project
i want to remove that default project
If you look very carefully at the messaging, it's saying that the name of the file is ".firebaserc" with a leading dot. This file indicates that firebase init was already run in this folder, and the contents of that file describe which project it's connected to (flairboat-48f7b). If you no longer want that file, delete it and start over. Since it starts with a dot, it might be hidden from normal view, but you can be sure that it exists.
you should write:
firebase use --add
and it work! You get the option to choose the preject from firebase.
I ran into the same issue.
Due to a small mistake in setting up the project in firebase, I had to delete it.
But later, I realized that my application NEEDS the default project to be hosted from firebase.
Since I found no shortcuts and running out of time, I did "this" to fix the issue in 10 minutes...with a 5-Step-Process. This is not a "Clever tip". But if you want things up and running soon, you can try this...
Create a new project (in my case, it's React project in VS Code IDE) using - npx create-react-app newprojectname to create a new react project with a different file name.(Don't delete or replace your previous project yet... )
While the new project is being created, create a new project in firebase to host your project.
Copy the folder from your old project that has all your work (it's "src" folder in case of React) and replace the "src" folder in the new project you created in your local machine.
Install all dependencies...Don't forget to add any dependencies you added to you old project. Look at the package.json file of the old project and import all dependencies.
Hit the start command (npm start in my case) and see your project running.
*I'll update if I found some firebase secret to resolve this issue. You can look for the same.
Ensure your firebase project support email and firebase initialize login email are same. If different? It won't be worked. so you must ensure it that two email (firebase project support email and firebase initialize email) are same.

Unlink an existing firebase app?

I want to "Link to new or existing Firebase project & app"
but the crashlytics dashboard told me my project is already linked,
how to unlink my existing project ?
To unlink your Fabric app from Firebase, follow the following steps:
Go to The Firebase project settings
Go to Integrations
Select the Fabric "Manage" link
Click the "Unlink Fabric App"
Very late but if someone still having this problem:
1- try to unlink on firebase dashboard as explanined in this response: https://stackoverflow.com/a/49229545/5679560
2- if the option to remove fabric doesn't appear use this direct link
https://fabric.io/remove_firebase_crashlytics?clientId=CLIENT_ID&projectId=PROJECT_ID
CLIENT_ID is your Firebase Client ID. This begins with "android:" or "ios:" and is followed by either your package name (Android) or bundle ID (iOS)
PROJECT_ID is your app’s containing Firebase project ID, which can be found by going to Project Settings. This is also present in the URL of your Firebase console, i.e. https://console.firebase.google.com/project/
you can check more info in this answer https://stackoverflow.com/a/50003432/5679560

Resources