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”.
iOS
Select “iOS” and “Xamarin”.
Android
Select “Android” and “Xamarin”.
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
.
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.
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.
Spot on with what I wanted to try.
Got me sorted out within minutes, thanks for writing this!
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 !
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.