Share via

Firebase implementation in MAUI mobile application

Yeswanth Srikanth 0 Reputation points
2026-04-09T14:10:06.41+00:00

Hi, I need to implement firebase analytics and Crashlytics in my MAUI mobile application using .NET 10 and I am currently doing POC in that so can you please help me with giving steps to implement firebase and log user in firebase console and Crash report as well.

Developer technologies | .NET | .NET MAUI
0 comments No comments

1 answer

Sort by: Most helpful
  1. Marcin Policht 85,255 Reputation points MVP Volunteer Moderator
    2026-04-09T14:20:50.6966667+00:00

    This involves using the Plugin.Firebase library (e.g., v4.0.0+). Create a Firebase project, add Android (google-services.json) and iOS (GoogleService-Info.plist) configuration files to the respective Platforms folders, set build actions, and initialize the plugin in MauiProgram.cs for both platforms.

    Step 1: Firebase Console Setup

    1. Create Project: Go to the Firebase Console and create a new project.
    2. Android: Add an Android App. Register using the package name from your .csproj file. Download google-services.json.
    3. iOS: Add an iOS App. Register using the Bundle ID. Download GoogleService-Info.plist.

    Step 2: MAUI Project Configuration

    1. Install Nuget Packages: Install the following in your MAUI project:
      • Plugin.Firebase (Main plugin)
      • Plugin.Firebase.Analytics
      • Plugin.Firebase.Crashlytics
    2. Add Configuration Files:
      • Android: Move google-services.json to Platforms/Android/. Right-click the file, select Properties, and set Build Action to GoogleServicesJson.
      • iOS: Move GoogleService-Info.plist to Platforms/iOS/.
    3. Configure Android:
    • Open Platforms/Android/AndroidManifest.xml and ensure internet permissions are enabled.
    • Update Platforms/Android/Resources/values/strings.xml to include Firebase config values if needed, although GoogleServicesJson often handles this.

    Step 3: Initialize Firebase (MauiProgram.cs)

    Initialize the plugin in your MauiProgram.cs to enable services .

    using Plugin.Firebase.Auth;
    using Plugin.Firebase.Shared;
    
    public static class MauiProgram
    {
        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .RegisterFirebase(); 
    

    Step 4: Log User and Crash Report

    Log User (Analytics): Use this to identify users in the console.

    using Plugin.Firebase.Analytics;
    
    CrossFirebaseAnalytics.Current.SetUserId("user_id_12345");
    CrossFirebaseAnalytics.Current.SetUserProperty("user_type", "tester");
    

    Log Custom Event (Analytics):

    CrossFirebaseAnalytics.Current.LogEvent("button_clicked", "button_name", "test_button");
    

    Log Exception (Crashlytics): To test, force a crash.

    using Plugin.Firebase.Crashlytics;
    
    try {
        throw new Exception("Test Crash for POC");
    } catch (Exception ex) {
        CrossFirebaseCrashlytics.Current.RecordException(ex);
    }
    

    Ensure CrossFirebase.Initialize() is called inside the OnCreate (Android) or FinishedLaunching (iOS) lifecycle, or Crashlytics will not start. In Visual Studio, you need to set the build action to GoogleServicesJson for google-services.json. It will likely take a few minutes for analytics/crashes to appear in the Firebase console.

    For details on setting up the required configuration files, refer to the official Firebase Android setup guide


    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.