Hockey App For Xamarin Forms? No Problem!

One of the projects I’ve been working on has involved mobile DevOps with a Xamarin Forms app. The first platform that came to mind was HockeyApp, as it’s new “Preseason” (a nice way of saying Beta) features provided us with a means of tracking custom events that happen in the app. Our first roadblock, however, was learning that while there were Xamarin.Android, Xamarin.iOS, and UWP packages, there wasn’t a universal one we could include in Xamarin.Forms. Did this stop us? Of course not! We just needed to use Dependency Injection to see this project through. Steps on how we did what we did are below:


Shared and Android Project Instructions



From there, search and add the HockeyApp for Android package and click “Add to App”


Now that we’ve got the correct package installed, we’ll just need to use Dependency Injection to correctly use this library when necessary. In our case, we wanted to track custom events, but any platform specific feature in the SDK should apply.

In the Shared project, create an interface. We named ours IMetricsManager. Create method stubs for any methods you’ll be needing to implement down the line like this:

Once that’s taken care of, feel free to call that method stub wherever needed in your code. We used ours to determine user themes in a switch statement, but the syntax for calling it is as follows:

Using the DependencyService class built into Xamarin.Forms allows us to take advantage of the interface and each platform’s unique implementation. IMetricsManagerService is the interface we created in the shared project, and “TrackEvent” was just the method stub we created.

Back to the Android Project!

The next thing we’ll need to do is implement the interface we just created. We’ll need to do that specifically in each platform’s project. In this case, we’ll focus on Android (But iOS is soon to come!).

There are a couple of key components in this class we’ll have to discuss. The first is the assembly reference before the namespace is defined. This is important for how dependency services works in Xamarin.Forms. In the “typeof” operator, we pass in the location and name of the class we wish to utilize. Another thing to note is that the class directly inherits from the interface we created. Finally, we make sure to implement the exact same method signature listed in the interface.


And we’re done! And easy peezy (peasy?) way to use dependency injection to implement HockeyApp in Xamarin.Forms. Hope this helps!


  1. Christopher Leong said:

    Is there any way for me to contact you? I am currently quite new to Xamarin itself thus would like to ask you more on this implementation

    September 20, 2016
  2. Senthamizh said:

    Is there any way to integrate hockeyapp to XF-windows ??

    October 25, 2016

Leave a Reply

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