question

NaveedAhmadHematmal avatar image
0 Votes"
NaveedAhmadHematmal asked JarvanZhang-MSFT commented

Organization Firebase database configuration in a Xamarin.Forms app

I have an open-source solution for Vaccine Distribution and Tracking. The solution includes two projects, one in asp.net for Admins and one in Xamarin.Forms for Volunteers, and I have configured the Firebase Project for a real-time database and Authentication provider [in development]. Admin is responsible for creating accounts for volunteers, and then volunteers are downloading the app from the play store and can access the app via the email and password created by the admin.

Now, here is the problem. An organization or a team wants to configure this app for a region. They are configuring their firebase real-time database with the admin panel and creating accounts for the volunteers., but the configuration I mean API Key and Project URL is not set on the mobile apps. Volunteers should only have emails and passwords, but how to configure them for the firebase their organization is using.

I have a solution, but it has a problem within it.
I have a page that appears once and at a first-run before the login page, and it asks about the API key and Project URL. But there is the problem, the admin won't give the API key and the project URL, as I know that is not a good practice.

dotnet-xamarin
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, NaveedAhmadHematmal. To access/consume the firebase database, we just need to obtain the database url to initialize the FirebaseClient. This should have been configured in the project, it doesn't require the user to do some work.

FirebaseClient firebase = new FirebaseClient(database_url);

You could search with the keyword as Xamarin.Forms Firebase Realtime Database to check the related document.

0 Votes 0 ·

Different users have different firebase accounts. How I can configure my app for a specific firebase! It is a general app everyone can have his firebase database and use this app with it.

0 Votes 0 ·

You could pass the current user's id to the FirebaseClient when operating the database.

var user = auth.SignUpWithEmailAndPassword(EmailInput.Text, PasswordInput.Text);

if (user != null)
{
    await firebaseClient
           .Child("Persons")
           .Child(auth.CurrentUser())
           .PostAsync(new Person() { ... });
}

Check the doc: https://firebase.google.com/docs/database/android/read-and-write#read_data

0 Votes 0 ·
Show more comments

0 Answers