Getting Started
ReferralHero Kotlin / Java SDK
Getting Started
To start using the ReferralHero SDK, you will need to add it to your project as a dependency.
Step 1. Add the JitPack repository to your build.gradle file
Add it in your root build.gradle/setting.gradle
at the end of repositories:
Step 2. Add the following to your build.gradle
file:
build.gradle
file:for KTS (1.0.6 as in Last Version available):
Step 3. Add Permission:
The ReferralHero SDK requires the following permissions. Add them to your AndroidManifest.xml file if they are not already present:
If you are not targeting the Google Play Store, you need to add the following permission:
Step 4. Set up Proguard:
If you are not publishing your app in the Google Play Store, add the following com.sdk.rh
rule:
Step 5. Set up install referrer intent:
If you are working with a store that supports the INSTALL_REFERRER
intent, you can capture this with a broadcast receiver. Add the following receiver
inside the application
tag in your AndroidManifest.xml
:
This receiver will retrieve the install referrer using below code in your file where you want to retrieve install referrer and register BroadcastReceiver
in your main activity.
If you are using a different broadcast receiver, you will need to set it up to communicate with the ReferralHero SDK. Follow these instructions to enable communication with the ReferralHero SDK broadcast receiver.
Multiple broadcast receivers
The ReferralHero SDK supports the INSTALL_REFERRER
intent using a broadcast receiver. If several sources need to register a receiver, you will need to add your own BroadcastReceiver
.
This receiver will call all the other receivers you want to support. Here is an example of a broadcast receiver:
If you are using your own broadcast receiver, you can pass the intent content to other receivers. Make sure to pass this information to the Adjust broadcast receiver and any others that need it:
Step 6. Integrate the SDK into your App:
If you are integrating the Adjust SDK into a standard app, follow the Setup SDK steps below.
Setup SDK
We recommend using a global Android Application class to initialize the ReferralHero SDK. If you do not have this set up, follow these steps:
Create a class that extends the
Application
.Open the
AndroidManifest.xml
file and locate the<application>
element.Add the
android:name
attribute and set it to the name of your application class. For example, if yourApplication
class is namedGlobalApplication
:
In your Application class, find or add the
onCreate
method. Add the following code to initialize the ReferralHero SDK:
You can find your ReferralHero API token and Tracking Code in your ReferralHero dashboard.
Get your API_TOKEN from the ReferralHero Dashboard -> API : https://app.referralhero.com/dashboard/apis
Back in the ReferralHero dashboard, click to edit your desired Campaign
Then the Installation tab, then Mobile App Installation
Get your UUID: The 12-letter id that starts with ‘MF’ in Edit Campaign > launch > Mobile app installation, e.g. MF15298bba6d
Now, the initRHSDK should look like this:
This step is mandatory to Set up your ReferralHero API token and Tracking Code in your AndroidManifest.xml file. Without this ReferralHero SDK does not work properly or you can not use SDK Features.
You should add it to your app's AndroidManifest.xml. More about this can be found on ReferralHero dashboard > Campaign > Installation > Instructions.
Following the values we got for our campaign:
In the Goal section of your Campaign settings, ensure you have added the Google Play and Apple App Store links and a default referral link for desktop web users.
Well done! You should now be able to build and run your campaign. Before using the more advanced features of the SDK, you should make sure you have reviewed the following important concepts:
Getting Started
Setup SDK
There are a few major components in the SDK that you can include in your app check out Public Methods.
Tracking Referrals
Now that you have implemented the SDK, you can start identifying and tracking referrals!
For that, you will need 2 things:
Universal Link
Your Integrated App
The RH SDK Pulls information from your Device, like this:
The format for android screen sizes is not native to RH, and the format should be parsed to RH accepted, such as:
With this information, you should be able to add the subscriber data, with the Get Referrer, Add Subscriber, Create Pending Referral, or Track Referral methods to automatically identify or track a referral:
To further understand the implementation of these methods, please check the Public Methods section, and our Github Sample Project.
Last updated