Initial SDK Setup

Installing the Braze SDK will provide you with basic analytics functionality as well as working in-app messages 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 Braze SDK binding.

Option 1: Nuget

The simplest integration method involves getting the Braze SDK Bindings from the central repository. In the Visual Studio sidebar, right click Packages folder and click Add Packages.... Search for ‘Braze’ and install the AppboyPlatform.AndroidBinding package into your project.

Option 2: Source

The second 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 Braze Android SDK.

Project Reference

The Braze Nuget package depends on the the Xamarin.Android.Support.v4 Nuget package.

Step 2: Configure the Braze 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:

Be sure to substitute REPLACE_WITH_YOUR_API_KEY with the API key located the App Settings page of the Braze 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" />

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 Braze dashboard (along with device information and other analytics).

Consult the Android integration instructions for more in depth discussion of best practices for the basic SDK integration.