Xamarin In-App Marketing Setup

Prerequisites

TUNE recommends having a PROD and DEBUG app in our system. You can switch between builds automatically by using debug macros. Create separate App IDs for the development and production builds of your app so that changes to your development build do not affect your production build (until you’re ready to push them to your production app audience).

You need to have two apps in In-App Marketing for each one of your apps if you support two platforms. One platform is for production and one for development.

For more information about creating unique App IDs/package names, please visit Creating Unique Package Names.

Set Up

Implement version 5.0+ of the plugin:

https://www.nuget.org/packages/Tune.Xamarin.Android/
https://www.nuget.org/packages/Tune.Xamarin.iOS/

Android:

Create a new Application class, or update an existing class and add the following initialization calls:

using Android.OS;
using TuneSDK;
using Com.Tune.MA.Application;
 
namespace YourAwesomeApp
{
    [Application]
    public class MainApplication : Application
    {
        public MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
        {
        }
 
        public override void OnCreate()
        {
            base.OnCreate();
            // Allow TUNE to hook into the activity lifecycles
            if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich) {
                RegisterActivityLifecycleCallbacks (new TuneActivityLifecycleCallbacks ());
            }
            Tune tune = Tune.Init(this.ApplicationContext, "your_advertiser_id", "your_conversion_key");
        }
    }
}

If your app supports a minimum SDK version below 14, then also extend TuneActivity for each of your Activities.

using Com.Tune.MA.Application;
 
namespace YourAwesomeApp
{
    public class MainActivity : TuneActivity

Enabling In-App Marketing

To enable In-App Marketing:

Android:
In your Application onCreate, call the Tune.Init overload with turnOnTMA = true:

[Application]
public class MainApplication : TuneApplication
{
    public MainApplication(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
    {
    }
 
    public override void OnCreate()
    {
        base.OnCreate();
        // Allow TUNE to hook into the activity lifecycles
        if (Build.VERSION.SdkInt >= BuildVersionCodes.IceCreamSandwich) {
            RegisterActivityLifecycleCallbacks (new TuneActivityLifecycleCallbacks ());
        }
        Tune tune = Tune.Init(this.ApplicationContext, "your_advertiser_id", "your_conversion_key", true);
    }
}

iOS:
In /Resources, add a TuneConfiguration.plist file with the Boolean key-value:
TurnOnTMA : YES

Set Up Push Notifications

Across all platforms, it is important to establish push notifications after your initial SDK install.
For more information on how to set up push notifications and configure campaigns to send out targeted push messages, see Push Notifications.

 

No Comments

Leave a reply