Diagnose Xamarin.Forms errors, crashes and performance issues with ease
Posted Jun 27, 2019 | 4 min. (681 words)Software quality is vital to user experience. If your users are experiencing problems with your mobile app, you simply need to know about it.
That’s why today, we’re announcing our new Raygun4XamarinForms provider for Crash Reporting and Real User Monitoring.
With this highly requested release, if you are developing with Xamarin Forms, you can integrate one provider and get 100% code coverage across both Android and iOS platforms — so you can enjoy accurate cross-platform error and user monitoring all in one place.
Raygun Crash Reporting offers developer-friendly mobile crash reports for surfacing problems that your customers experience, allowing you to pinpoint the root cause of an error, while Real User Monitoring will surface slow-loading parts of the app to help you diagnose the cause.
Though many mobile developers judge their software quality on whether or not their application is crash-free, slow network calls and slow loading views can harm the end user experience. That’s why being able to see the performance timings of user sessions and how they encountered an issue is so important.
How to get started with Raygun and Xamarin.Forms
First of all you’ll need a Raygun account. If you aren’t already a Raygun customer, create an account and follow the instructions after selecting Xamarin.Forms as the language you wish to monitor. Here’s how to get started with Crash Reporting:
Installation
The provider targets .NET Standard 2.0 and is available through NuGet packages found here. The currently supported platforms are Android and iOS with the following versions or newer:
- Xamarin.Android 8.0
- Xamarin.iOS 10.0
Initialization
The initialization of Raygun must occur early in the app’s initial startup phase. We recommend doing this in the constructor of your Application
class. Using the static Init
method will also ensure a shared RaygunClient
instance is available through the static property Current
.
public partial class App : Application
{
public App()
{
InitializeComponent();
// Initialising the Raygun client
RaygunClient.Init("_API_KEY_");
RaygunClient.Current.EnableCrashReporting();
// Remaining application setup logic
MainPage = new MainPage();
}
}
Each platform being targeted requires an additional configuration step using the RaygunPlatform
class in the following places.
For Android
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
{
// MainActivity startup logic
base.OnCreate(savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
// Configure Raygun for the current platform
RaygunPlatform.Configure(this);
}
}
For iOS
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
// AppDelegate startup logic
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
// Configure Raygun for the current platform
RaygunPlatform.Configure();
return base.FinishedLaunching(app, options);
}
}
It really is that simple to set up and Raygun will start monitoring your Xamarin.Forms applications for crashes that users experience, with all the diagnostic details around what happened and why as users interact with your application.
- For an example on integrating, head to the sample app.
- Crash Reporting documentation
- Real User Monitoring documentation
Performance matters - When crashes just aren’t enough
Unlocking the power of Real User Monitoring, you can understand how users are navigating through your app and any performance issues they encounter along the way. Slow mobile app experiences are just as frustrating as crashes, so gaining visibility over these issues is paramount to creating winning user experiences.
With Real User Monitoring and Crash Reporting working together in the Xamrin.Forms provider, you can see the full user session, including when a crash occurred and detailed diagnostic information to resolve problems with greater speed and accuracy.
Understand how your software is changing by comparing versions
Furthermore, on the theme of software visibility, Real User Monitoring will show you user sessions by application versions. Handy for seeing whether performance issues have improved or got worse as new releases have hit the app stores, Raygun offers a window into where you can improve your mobile performance.
Did the latest version of your app solve problems or introduce them? Now you’ll know.
Already a Raygun customer?
If you were previously using a platform-specific Xamarin provider with Raygun, you may want to migrate to the new cross platform provider. Head to the Raygun4Xamarin.Forms set up instructions in the documentation for both Crash Reporting and Real User Monitoring.