Integration

A comprehensive guide to integrating your Android app with InviteReferrals. The new SDK for Android helps you to run a referral campaign in InviteReferrals. Read this guide to learn the basic integration of the referral campaign, how to track the events, how to show a welcome message, and other important information via FAQs.

Read this guide to integrate your Android app with InviteReferrals Android SDK.

Requirements

  1. Android 4.4+ device or emulator with "Google Play Store (Services)" installed
  2. Android Studio
  3. Configured InviteReferrals App and Platform

Add SDK Dependencies

Follow the below steps:

  1. Add the following repository to your project-level build.gradle file:
repositories {
     google()
     mavenCentral()
}
  1. Add the following dependency to your build.gradle file of your app.
dependencies {
     implementation 'com.android.installreferrer:installreferrer:1.1.1'
     implementation 'com.invitereferrals.invitereferrals:invitereferrals:v1.2.6.2'
}
dependencies {
     implementation 'com.android.installreferrer:installreferrer:1.1.1'
     implementation 'com.invitereferrals.invitereferrals:invitereferrals:v1.2.6.2'
}

Add Manifest Permissions

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

SDK Initialization

Add ​our register​ ​method​ to your application class's ​onCreate​() ​method​.

import android.app.Application
import com.invitereferrals.invitereferrals.InviteReferralsApplication

class MyApplication : Application() {

   // NOTE: Replace the below with your own INVITEREFERRALS_BRAND_ID & INVITEREFERRALS_BRAND_ENCRYPTION_KEY
   private val INVITEREFERRALS_BRAND_ENCRYPTION_KEY: String = "##################################"
   private val INVITEREFERRALS_BRAND_ID: Int = #####

   override fun onCreate() {
       super.onCreate()

       InviteReferralsApplication.register(this, INVITEREFERRALS_BRAND_ID, INVITEREFERRALS_BRAND_ENCRYPTION_KEY);

   }
}
import android.app.Application;

import com.invitereferrals.invitereferrals.InviteReferralsApplication;

public class ApplicationClass extends Application {

   // NOTE: Replace the below with your own INVITEREFERRALS_BRAND_ID & INVITEREFERRALS_BRAND_ENCRYPTION_KEY
   private String INVITEREFERRALS_BRAND_ENCRYPTION_KEY = "##################################";
   private int INVITEREFERRALS_BRAND_ID = #####;
  
   @Override
   public void onCreate() {
       super.onCreate();
       
       InviteReferralsApplication.register(this, INVITEREFERRALS_BRAND_ID, INVITEREFERRALS_BRAND_ENCRYPTION_KEY);

   }
}

📘

Note

In the above example, dummy Brand ID and Encryption Keys are shown. Kindly login to your IR_Account to see your credentials.