Initial SDK Setup

Installing the Appboy SDK will provide you with basic analytics functionality as well as a working in-app slideup message with which you can engage your users.

Get the Xamarin binding

Step 1: Get the Xamarin binding

A Xamarin binding is a way to use native libraries in Xamarin apps. The implementation of a binding consists of building a C# interface to the library, and then using that interface in your application. See the Xamarin documentation.

There are two ways to include the Appboy SDK binding.

The first integration method is to include the binding source found here. Under appboy-component\src\android you will find our binding source code; adding a project reference to the AppboyPlatform.XamarinAndroidBinding.csproj in your Xamarin application will cause the binding to be built with your project and provide you access to the Appboy Android SDK.

Component Reference

The second integration method involves getting the Appboy SDK Bindings component from the Xamarin Component store. In your application, if you right click the Components folder and click Get More Components you will be taken to the component store. Search for ‘Appboy’ and install the component into your project.

Component Reference

Note: We require the Xamarin.Android.Support.v4 nuget package/component. If you install as a component this should automatically be added. If you link to our source it will be pulled in as part of that project. If you need to update that package you can do so by manually updating your packages.config (or the one in our source code).

Step 2: Configure the Appboy SDK in appboy.xml

Now that the libraries have been integrated, you have to create an appboy.xml file in your project’s Resources/values folder. The contents of that file should resemble the following code snippet:

Note: Be sure to substitute REPLACE_WITH_YOUR_API_KEY with the API key located the App Settings page of the Appboy dashboard.

    <?xml version="1.0" encoding="utf-8"?>
    <string name="com_appboy_api_key">REPLACE_WITH_YOUR_API_KEY</string>

Step 3: Add Required Permissions to Android Manifest

Now that you’ve added your API key, you need to add the following permissions to your AndroidManifest.xml file:

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

Note: In Xamarin Studio you can click Options->Android Application and select the Internet and AccessNetworkState permissions through a GUI instead of modifying your AndroidManifest.xml source directly.

Implementation Example See appboy.xml in the Android sample app for an example implementation.

Step 4: Tracking User Sessions and Registering for In-App Messages

To enable user session tracking and register your app for in-app messages, add the following call to the OnCreate() lifecycle method of the Application class in your app:

RegisterActivityLifecycleCallbacks(new AppboyLifecycleCallbackListener());

SDK Integration Complete

You should now be able to launch your application and see sessions being logged to the Appboy dashboard (along with device information and other analytics). Note: Consult the Android integration instructions for more in depth discussion of best practices for the basic SDK integration.


Logging Custom Events

See the Android integration instructions for in depth discussion of event tracking best practices and interfaces.


Setting Custom Attributes

See the Android integration instructions for in depth discussion of attribute tracking best practices and interfaces.


Logging Purchases

See the Android integration instructions for in depth discussion of revenue tracking best practices and interfaces.

Appboy.GetInstance(this).LogPurchase("YOUR_PURCHASE_NAME", 100);

Social Data Tracking

See the Android integration instructions for in depth discussion of social data best practices and interfaces.

You can see the Xamarin binding accessing these interfaces in the HomeFragment.cs of our sample app. The sample code logs a social share and populates the Appboy user with data from the social networks. The code looks like:

// Record Facebook Data
FacebookUser facebookUser = new FacebookUser("708379", "Test", "User", "", "Test", "Testtown", Gender.Male, new Java.Lang.Integer(100), new String[]{"Cats", "Dogs"}, "06/17/1987");

// Record Twitter Data
TwitterUser twitterUser = new TwitterUser(6253282, "Test", "User", "Tester",  new Java.Lang.Integer(100), new Java.Lang.Integer(100), new Java.Lang.Integer(100), "");

Customer Feedback

See the Android integration instructions for information on how to integrate the feedback form into your Xamarin Android app. Furthermore, you can look at the sample application for implementation samples.

In brief: add an AppboyFeedbackFragment

AppboyFeedbackFragment feedbackFragment = new AppboyFeedbackFragment();

to your view hierarchy. The default way to handle returning from submitting a Feedback form is popping the back stack. Do this when the feed is finished by adding an IFeedbackFinishedListener to the feedbackFragment.

feedbackFragment.SetFeedbackFinishedListener(new FeedbackFinishedListener(Activity.SupportFragmentManager));
class FeedbackFinishedListener : Java.Lang.Object, AppboyFeedbackFragment.IFeedbackFinishedListener {
  FragmentManager mFragmentManager;

  public FeedbackFinishedListener(FragmentManager supportFragmentManager) {
    mFragmentManager = supportFragmentManager;

  public void OnFeedbackFinished () {
    Console.WriteLine ("Feedback finished");
    mFragmentManager.PopBackStack ();


Push Doesn’t Appear After App is Closed from Task Switcher

If you observe that push notifications no longer appear after the app is closed from the task switcher, your app is likely in Debug mode. Xamarin adds scaffolding in Debug mode that prevents apps from receiving push after their process is killed. If you run your app in Release Mode, you should see push even after the app is closed from the task switcher.

Custom Notification Factory Not Being Set Correctly

Custom notification factories (and all delegates) must extend Java.Lang.Object to work properly across the C#/Java divide. See Xamarin’s documentation on implementating Java interfaces for more information.