Xamarin for Android

Pulse for Xamarin.Android

Setup instructions

1. Install the Raygun4Net provider

In Visual Studio or Xamarin Studio, use the NuGet package manager to find 'Raygun4Net'. Select the 'Mindscape.Raygun4Net' package, then install the package.

2. Enable Pulse in your app

In the main Activity of your application, initialize the RaygunClient and attach the Pulse feature. Your app API key is displayed when you create a new application in your Raygun account, or when you unlock Pulse for an existing app, or can be viewed in the "Application settings".

protected override void OnCreate(Bundle bundle)
{
  base.OnCreate(bundle);
  RaygunClient.Initialize("YOUR_APP_API_KEY").AttachPulse(this);

  // Your code
}

If you have previously enabled Raygun Crash Reporting in your app, you may notice the code above is using a new RaygunClient API. Previously, crash reporting was set up via the static RaygunClient.Attach method which takes your Raygun app API key. The RaygunClient now has a static Initialize method, and subsequent AttachPulse and AttachCrashReporting functions that have their own options and can be chained together.

The old and new methods are compatible with each other, but we recommend using the new Initialize, AttachPulse and AttachCrashReporting methods so that you only need to pass your Raygun app API key once.

3. Provide a user identifier

By default, the Raygun provider will give a unique guid to each user for distinguishing between them. If possible, we highly recommend providing your own unique identifiers for your users which can be done with the code below. The string you pass into the constructor can be whatever unique user id that works best for you - email address is a recommended example. Providing the first name and full name is optional.

RaygunClient.Current.UserInfo = new RaygunIdentifierMessage(emailAddress) {
  FirstName = firstName,
  FullName = fullName
};

Done

Pulse messages will be sent to Raygun as soon as the app starts up. So once you've set up Pulse in your app, run it up and go to your Pulse dashboard to see the data it collects. Of course Pulse is most valuable once your app is out there in the store.

Network calls

You can manually log the timings of network calls using the following Raygun4Net API.

RaygunClient.Current.SendPulseTimingEvent(RaygunPulseEventType.NetworkCall, "GET https://raygun.com", 1234);

The name string can be whatever works best for you - the HTTP method and url is a recommended example. The duration is the milliseconds that you've measured the network call to take.

Details about the network calls that you log can be found in the Performance tab of your Pulse for mobile dashboard.

Documentation missing?

If we don't have documentation about your desired topic, send us a message and we'll create it for you.