Using App Center Diagnostics & Analytics with .NET MAUI

Note: Microsoft has announced that they will be retiring App Center. I suggest you look at other alternatives for diagnostics and analytics for .NET MAUI.

App Center is alive! With a pre-release version of the App Center packages, they’re showing that they’re adding .NET MAUI support. Gerald Versluis posted a great video with an overview of the capabilities of this pre-release. This post will be heavily inspired by his video and will serve as a written guide for how you can collect diagnostics and analytics for your .NET MAUI application. I recommend watching his video for an excellent run-through.

Register your application

You will first have to register your application in the App Center portal. This is a bit different depending on your target platform. I will show you how you can do this for Windows, iOS and Android. Note that the portal hasn’t been updated yet for MAUI so we’ll have to select the options that are the closest equivalents.

Windows

Click “Add new app” and Select “Windows” and “UWP”.

Selections for creating the .NET MAUI Windows app in App Center.

iOS

Select “iOS” and “Xamarin”.

Selections for creating the .NET MAUI iOS app in App Center.

Android

Select “Android” and “Xamarin”.

Selections for creating the .NET MAUI Android app in App Center.

Install the package

In your .NET MAUI application, open the NuGet Package Manager and search for Microsoft.AppCenter. Remember to check the “pre-release” checkbox. Go ahead and install both the version 5.0.0-preview.1 of Microsoft.AppCenter.Analytics and Microsoft.AppCenter.Crashes.

The App Center packages in NuGet Package Manager.

Initialization

We’ll do the initialization in MauiProgram.cs. Add the following line right before the return statement:

  AppCenter.Start("windowsdesktop={Your Windows App secret here};" +
                "android={Your Android App secret here};" +
                "ios={Your iOS App secret here};",
                typeof(Analytics), typeof(Crashes));

Replace Your Windows App secret here with the Windows app secret from App Center. You can find this by navigating to the Windows app in App Center and scrolling down to “Integrate app secret” in the “Overview” page.

App secret.

Do the same for your Android and iOS app and replace them respectively.

That’s all! Now you can start your app and you should pretty instantly see things popping up under Analytics.

If you want to test out crashes (Diagnostics) as well, add this line in f.ex. a button event handler or just in your startup code:

Crashes.GenerateTestCrash();

Note that you need to start your app again after the crash so that the crash report gets sent up to App Center.

I also have a GitHub sample for this, if you want to check it out.

3 thoughts on “Using App Center Diagnostics & Analytics with .NET MAUI”

  1. Outaded… AppCenter will be retired in Mars 2025…
    Thanks Microsoft, I’ve to migrate 48 customer applications to another “Diagnostics & Analytics” solution… and I didn’t find any suitable right now…

    AppCenter for MAUI : Barely released, already obsolete !

    1. Yeah, shame that they retired it. Hopefully this was helpful to those that used it before the announcement. I’ve updated my post with a notice about the retirement.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.