Connect Firebase Project under different project from another Google Cloud project - android

I currently have 2 firebase/google cloud projects. One for frontend and one for backend where app engine is hosted. I wanted to use firebase to send push notifications from the FCM token.
The code that I am using is the following:
Firebase.app = admin.initializeApp();
What this does is that it uses my backends firebase project not the firebase project of my frontend.
To connect to a different project's firebase I will have to do the following to my knowledge:
Firebase.app = admin.initializeApp({
credential: admin.credential.applicationDefault(),
});
And I will need to have an environment variable named GOOGLE_APPLICATION_CREDENTIALS
which will have to point to a google-credentials.json file containing the JSON object with the google credentials of the different applications.
I don't upload my google credentials json file as I am using cloud build from my Github.
I was trying the following approach:
Create a Base64 string of the json object and store it in a variable and then create a json file from the decoded base64 string and then point to the GOOGLE_APPLICATION_CREDENTIALS to the created file. But the google app engine does not allow for writing to files, so this is a dead-end unless there is something that will allow me to write to a file.
Is there some way I can link the firebase project of the frontend to the google cloud project of my backend so that the google cloud project directly links up the frontend's firebase project. If not then is there a way in which I can migrate the firebase project easily from the frontend firebase project to the backend firebase project?
Any suggestion would be a great help. Thanks!

There is no direct way to migrate the Firebase Application from one project to another project. You can refer to this stackoverflow thread to find this.
Also there is no way to migrate an App Engine application from one project to another. Instead you have to deploy the App Engine application in the new project.
So your concern narrows down to the fact that which one will be easier for you. I would suggest deploying the App Engine application in the same project where your Firebase frontend is already present. Because it seems easier as you only have to change the default project configuration in your SDK or Command Line Interface and follow this documentation.

Related

How to add firebase custom claims without admin SDK?

I am developing a Android app with firebase as backend. I heard about firebase admin SDK but I don't know how to create it. I am using firebase console in web interface.
Now how can I set customer claims for a user?
You cannot. You could add custom claims from your local computer instead of Cloud functions or run a node process locally if you just need to add claims for a few users but the Admin SDK is necessary.
Checkout Firebase Custom Claims without Cloud Functions for detailed explanation on setting up admin sdk locally. You could just locally run functions or a node process to add claims as mentioned in there.

Sharing Android Studio project to Github without giving access to firebase database

So I have a personal project, which is on github, but is now private, because it uses firebase database, and using the app lets you control my house lights, etc.
How can I make my app public without letting using my database?
App doesn't require any authentication.
Don't check in your google-services.json file. This is where the app gains knowledge of how to access the database. Instruct the users of your source code to create their own Firebase project and add their own google-services.json file to the project to get their own database to work with.
By the way, if your app doesn't use Firebase Authentication and it's given permission to read and write the database, then anyone who knows the name of your project will also be able to read and write the database. The name of your database can be gained by simply breaking down the APK.

How to add Admin SDK api to android project

I am currently working in an Android application that requires to have Admin and regular users. To illustrate, the admin has the ability to manage the regular users like delete , modify their contents. According to my reserch that firebase provide Admin SDK API that can be realy sutiable for this issue but according to thier documention that Admin SDK cannot be used in the Android project itself and should be placed in the server-side of the project. In addition, i was tried to add the Admin SDK debendence to my project dependences but there is conflict between the libraries . I know what i was did is wrong to add the Admin SDK to the Bulid.gradle (app) but i did not manage to figure out how i can add the Admin SDK to my project.
What you've found is correct. Your case seems to be suitable for using Firebase Admin SDK.
Firebase Admin SDK needs a server app, on which it will be initialized.
Here you can find a full list of the prerequisites for setting-up Firebase Android SDK.
You can set-up Firebase Functions, which will hold your server-side code. Inside those functions you can also initialize the Firebase Admin SDK.
Please refer here for more information on Firebase Functions.
Here you can find a sample Firebase application which uses the Admin SDK. The sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.
Firebase Functions are built to serve as serverless code, as you develop your server-side logic, then deploy it to a managed environment on Google's cloud. Those functions can contain all the logic that you would like to have using Admin SDK.

Is firebase a server that has a mobile service

for one of my assignments I have to make an Android app and I have to use a server and a service which can be a mobile service or a web service. So I was thinking of using Firebase as it is real time and have some good features.
BUT
I want to know for the above requirements of my assignment is Firebase suitable.
Also, I have been told to submit a deployment unit, I am guessing the deployment unit in this case is the APK file. Am I right?
EDIT
In my assignment specification it says "Server deployed in the cloud and server must be micro-service or web-service or mobile-service of your choice" which made me choose Firebase. But I am confused if firebase's server is in the cloud and if it uses any of the services mentioned above :/
Yes, Firebase has great services such as Realtime Database, Analytics, Storage, Remote Config, ... which help you to build your app.
The deployment unit in Android is ".APK" file. (If you are gonna develop a library, it will be ".AAR" file (Android ARchive file))
Firebase is a cloud-based technology that permits you to make with no server-side programming. It offers features like Realtime Database, storage options, Notifications, authentication options, hosting and more and there is no server side code required. Just put in the configurations and Firebase would handle it. Firebase lets you store user information and sync data between them in realtime.

Same firebase project for both Android and iOS

My friend have finished setting up a Firebase backend for an Android application, and the project is on his private firebase account. Now I am starting to code the iOS version which should access the same Firebase backend.
My question is this... do I need to get his firebase email and password to work on the project or there​ is a way to import it to my account so I can work on it ?
tip: The solution should be like that, if any change happen in iOS or Android, must change in both of them.
You can add multiple developers to a single project, and you can have multiple apps added to your project. Do the following: your friend must add you to the project, and you must create an iOS application for that project in Firebase.

Categories

Resources