One firebase database for every customer - firebase

I have one mobile app, and every customer have a lot of data under user account. It is possible to make one database firebase for each customer ? Xamarin app...

You can create multiple databases directly from the Firebase Console as mentioned here.
In case you need to create the databases programmatically as new users sign up or so, then you need to use Firebase Realtime Database Management API.
To create a new database, make a POST request:
https://firebasedatabase.googleapis.com/v1beta/{parent=projects/*/locations/*}/instances

Related

Firebase Database secure data from project owner

I am not talking about security rules. I am developing an app and as a Database owner can see what my users store in my Firebase Realtime Database from console. From Data tab I can see full JSON tree. Can I hide data from me to make my users feel 100% secure?
There is no way to hide the data in the console from the owner of a project. While you can grant/deny access to the data for specific services for collaborators, owners can always see all services in the project.
If you want to not be able to see any of the user's data, you'll need to use some form of end-to-end encryption where the key is not stored in Firebase.

Customer specific Firebase storage

I have an Flutter app that use Firebase as backend. Initially, a Firebase project and a collection is created to store data from different customers using the app. A key field "Customer" is use to separate the data among different users in the big pool.
In order to enhance the security and customise the billing incure in Firebase, I would like to separate different customer with their own Firebase account/project/database setup, the process is:
Whenever a new customer install the app and run it at the first time, the app will ask the customer to create his/her firebase account and then pass the account information to the app. Then, the app can consume the customer specific firebase for their private data storage.
Is there any experts can give me a hints how can I achieve this?
Thank you!
To programmatically create a project you can use this GCP create API and then link it to Firebase with this API. But they'd need an existing account already.
Alternatively you can have them create the account and project on their own through the console, and then use the list API to get a list of projects, have them pick one, and get the project config.
All of these are pretty raw APIs though, so you'll have to play around a bit to get the calls exactly right. Many of the REST APIs will have an API explorer link, which is typically helpful in figuring it out.

Flutter get User Data from Firebase

I want to get User Data from firebase, I need the diplayName of a User. is there any way to get the displayName of a other user with his uid?
There is no way to look up information about another user in Firebase Authentication by using the client-side SDKs of Firebase, as that would be a security risk.
There are two common ways to allow searching the users in a secure way:
Write information about each user to a database (such as Cloud Firestore or the Realtime Database) when they register, and then search the database when needed. That way your code controls what data gets written and thus is searchable.
Firebase has Admin SDKs that run in trusted environments, such as your development machine, a server you control, or Cloud Functions. These SDKs have options to list users, which means you can search them. If you wrap one of the Admin SDKs in a custom API that you build and secure yourself, you can then call that from your Flutter code.
Also see:
React native firebase authentication searching
You can't get the name, or any other details of a user that is not currently signed in using FirebaseAuth.
Instead, you must create a node in your database where you store the name, and any other necessary details by querying the database.

How can one fetch the authorized users along with their details in Firebase

I have a Firebase project, which I'm currently using with android. I need to programmatically fetch details of the users authorized along with the UID, Email, etc. Exactly the way it is shown in firebase (with the search), this web portal will be given to the vendor or the person using it to verify the user's authenticity.
I've attached the screenshot from Firebase, I'm hoping to replicate it the same way with the search. If this is possible, how do I go about doing this?
It's not possible to list users from an Android app, using only the Firebase Authentication SDK. You can list users using the Firebase Admin SDK, but that can only be run on a backend you control, using service account credentials for your project.
It might be easier if you store user info in a database, to be queried by client code, rather than try to have your app try to access auth data directly.

what is the best way to manage FCM registration ID in database server?

I'm trying to use firebase cloud messaging service for my android application and I'm trying to find the best way to manage registration ID in database server.
I was thinking to create new table with userID,registrationId (where userID is unique for each user) in my database and insert new record once the user logs in successfully and remove that record when the user logs out. but there are some situation that the registration Id will be refreshed, I can get the new registration Id to save it in the database. but how can I get the old registration Id to remove it?
Are there better way to manage the registration Id in database?
note: a device can access one account but there are might be many devices that use the same account.
Depending on the user, you might want to also have an identifier for each device they use. But for a simpler explanation, I'll go with the scenario where each user only has a single device.
If you're using Firebase Database, then the simplest way to structure the nodes would be something like this:
pushTokens/
$userId: <registration_token_here>
Simple as that. You just pair the userId that you use in your app (possibly for authentication) and place the token there. On sign out, log the user out. When the user is currently signed-in and the token refreshes, handle it in onTokenRefresh(), send the new token to the DB, and replace the older one. Deciding to keep the old one for logging purposes is your call.
Possibly helpful posts:
Firebase Cloud Messaging - Managing Registration Tokens
Managing FCM device groups

Resources