Skip to content

.NET MAUI bindings for Firebase Performance Monitoring — Cross-platform wrapper for Android and iOS Firebase Performance SDKs using the CommunityToolkit NativeLibraryInterop template. Includes sample app and NuGet packaging.

License

Notifications You must be signed in to change notification settings

RobertWildgoose/Maui.FirebasePerformance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Maui.FirebasePerformance

Native Library Interop wrapper for Firebase Performance Monitoring in .NET MAUI

This project provides a cross-platform .NET MAUI wrapper for Firebase Performance Monitoring, making it easy to integrate Firebase Performance into your MAUI apps with a clean C# API. It leverages the CommunityToolkit.Maui.NativeLibraryInterop template to bridge native Android and iOS Firebase SDKs.


Features

  • Cross-platform support: Android and iOS
  • Easy-to-use C# interface for starting/stopping performance traces
  • Integrates seamlessly with .NET MAUI projects
  • Includes a sample MAUI app demonstrating usage

Getting Started

1. Add the NuGet Package

Include the package in your .NET MAUI project (replace with your package ID if published):

dotnet add package Maui.FirebasePerformance
  1. Firebase Setup

Android

Download your google-services.json from the Firebase Console.

Place it in Platforms/Android of your MAUI app.

Initialize Firebase in MainApplication.cs:

Firebase.FirebaseApp.InitializeApp(this);

iOS

Download your GoogleService-Info.plist from Firebase Console.

Add it to Platforms/iOS in your MAUI app.

Ensure Firebase/Performance pod is installed via CocoaPods.

Usage

using Maui.FirebasePerformance;

public partial class MainPage : ContentPage
{
    private readonly IFirebasePerformance _performance;

    public MainPage(IFirebasePerformance performance)
    {
        InitializeComponent();
        _performance = performance;

        // Enable performance collection
        _performance.SetPerformanceCollectionEnabled(true);

        // Start a performance trace
        var trace = _performance.StartTrace("app_startup");
        DoSomeWork();
        trace.Stop();
    }

    private void DoSomeWork()
    {
        // Simulate work
        Thread.Sleep(1000);
    }
}

API

IFirebasePerformance

  • void SetPerformanceCollectionEnabled(bool enabled) – Enable or disable performance monitoring.
  • ITrace StartTrace(string traceName) – Start a performance trace.

ITrace

  • void Start() – Begin trace measurement.
  • void Stop() – Stop the trace and send metrics to Firebase.

Sample App

The Firebase.Performance.Sample project demonstrates:

  • Initializing Firebase
  • Starting/stopping traces
  • Cross-platform usage in a MAUI app

Development

This project uses the NativeLibraryInterop template. To update or extend bindings:

  • Android: Add or update Gradle dependencies in Firebase.Performance.Android.
  • iOS: Update Podfile in Firebase.Performance.iOS and run pod install.
  • Generate bindings:

-- Android: Use Java binding syntax in ApiDefinition.cs -- iOS: Use Objective Sharpie to generate C# bindings for .framework headers

Build the solution, then run the sample app to test functionality.

License

This project is licensed under the MIT License. It uses Firebase SDKs which are governed by Firebase Terms of Service.

References

  • CommunityToolkit.Maui.NativeLibraryInterop
  • Firebase Performance Monitoring
  • .NET MAUI Documentation

About

.NET MAUI bindings for Firebase Performance Monitoring — Cross-platform wrapper for Android and iOS Firebase Performance SDKs using the CommunityToolkit NativeLibraryInterop template. Includes sample app and NuGet packaging.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published