• EnglishEspañol日本語한국어Português
  • Log inStart now

Monitor your .NET MAUI mobile app

Our New Relic .NET MAUI agent monitors your .NET MAUI mobile app and provides deep insights into your app's performance, errors, and user experience. Once you install and configure the .NET MAUI agent, you'll be able to:

  • Capture C# errors: Identify and fix problems quickly.
  • Track network requests: See how your app interacts with the backend.
  • Use distributed tracing: Drill down into handled exceptions and find the root cause.
  • Create custom events and metrics: Understand how your users interact with your app.
Summary view of a .NET MAUI mobile app in New Relic

one.newrelic.com > All capabilities > Mobile > (select your .NET MAUI app) > Summary: View .NET MAUI data, track HTTP requests and errors, and monitor how your app is performing over time.

(Recommended) Guided installation

To install the .NET MAUI agent, follow our guided install, located directly in the UI.

Manual installation

If you need to install the agent manually, follow these steps:

Review the requirements

Before you install our .NET MAUI agent, make sure your app meets these version requirements:

  • .NET version 7.0 or higher
  • For Android-native apps: Android 7 (API 24) or higher
  • For iOS-native apps:
    • iOS 11 or higher
    • Latest release of Xcode

Add the .NET MAUI agent to your project

First, you'll need to add our agent, a NuGet package, to your MAUI project:

  1. Open your .NET MAUI solution, select the project you want to add the agent to, and open its context menu.
  2. Click Add > Add NuGet packages, then select NewRelic.MAUI.Plugin.

Copy your application token from the UI

The application token is used for New Relic to authenticate your .NET MAUI app's data. To view and copy your application token in the New Relic UI:

  1. Go to one.newrelic.com, click Add data, then click Mobile.
  2. Select your .NET MAUI app.
  3. Go to Settings > Application and copy the displayed Application token.

You'll add this application token in the next step.

Add our agent configuration file to your .NET MAUI project

In your project, open App.xaml.cs and add the following code:

using NewRelic.MAUI.Plugin;
...
public App ()
{
InitializeComponent();
MainPage = new AppShell();
CrossNewRelic.Current.HandleUncaughtException();
CrossNewRelic.Current.TrackShellNavigatedEvents();
// Set optional agent configuration
// Options are: crashReportingEnabled, loggingEnabled, logLevel, collectorAddress, crashCollectorAddress, analyticsEventEnabled, networkErrorRequestEnabled, networkRequestEnabled, interactionTracingEnabled, webViewInstrumentation, fedRampEnabled, offlineStorageEnabled
// AgentStartConfiguration agentConfig = new AgentStartConfiguration(crashReportingEnabled:false);
if (DeviceInfo.Current.Platform == DevicePlatform.Android)
{
CrossNewRelic.Current.Start("<YOUR_APP_TOKEN>");
// Start with optional agent configuration
// CrossNewRelic.Current.Start("<YOUR_APP_TOKEN>", agentConfig);
} else if (DeviceInfo.Current.Platform == DevicePlatform.iOS)
{
CrossNewRelic.Current.Start("<YOUR_APP_TOKEN>");
// Start with optional agent configuration
// CrossNewRelic.Current.Start("<YOUR_APP_TOKEN>", agentConfig);
}
}

Make sure you paste your application token(s) into appToken = "" in the code above. If you deployed your hybrid app to both iOS and Android platforms, you'll need to add two separate tokens: one for iOS and one for Android.

(Android only) Add permissions

If you have an Android-native app, you'll need to add INTERNET and ACCESS_NETWORK_STATE permissions in your Platforms/Android/AndroidManifest.xml file:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

Customize the agent instrumentation

Need to customize your agent instrumentation? Our public mobile SDK API methods let you collect custom data, configure default settings, and more.

The following customizations are available for the .NET MAUI agent.

If you want to...

Use this method

Record breadcrumbs to track app activity that may be helpful for troubleshooting crashes.

Record breadcrumbs

Track a method as an interaction.

Start interactions

Stop interactions

Record custom metrics.

Record custom metrics

Record handled exceptions.

Record handled exceptions

Record custom attributes and events.

There are several ways to report custom attributes and events:

Track custom network requests and failures.

Track HTTP requests

Track failing HTTP requests

Shut down the agent.

Shut down the agent

Enable/disable default mobile monitoring settings.

Enable/disable monitoring features

Run a test crash report.

Test crash reporting

Troubleshoot HTTP errors

Missing HTTP data in the UI?

After installing the .NET MAUI agent, wait at least 5 minutes. If no HTTP data appears on the HTTP errors and HTTP requests UI pages, make sure you used HttpMessageHandler in HttpClient.

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.