# Public Methods

ReferralHero provides a very simple and efficient approach for an application to communicate with our SDK.

A whole set of public methods exists within the SDK using which you can easily access most of the data, execute various SDK tasks, invoke from a large set of APIs, etc.

RH is the main SDK class and point of interface for an application to communicate with the SDK.

Most of the methods you will use will be from this class, so it's very important to instantiate it before actually starting to use it. Though it can be instantiated from any class, it is highly recommended to do so on the very first screen of your app, so that the SDK would be ready to use by the time your app transits to the main screen.

Use the following code to instantiate the RH  class:

{% tabs %}
{% tab title="Java" %}

```java
RH rh = RH.getInstance();
// or
RH rh = RH.initRHSDK(context, null, null);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.instance
// or
val rh = RH.initRHSDK(context, null, null);
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
NOTE:

As RH class uses singleton format, you can use the same above code to retrieve its instance throughout your app.
{% endhint %}

Below is a full list of public methods provided by the ReferralHero SDK, you can check them out to know their use case, return type, and input parameters:

### **1. Add Subscriber**

This method is most commonly used to add a non-referred subscriber or create a referral (if identified) after a user successfully signs up or logs in to your app.

When using this method please take note of your Campaign Goal as our tracking logic will depend on if you are tracking a single or multi-step conversion event.

{% hint style="info" %}
**GOAL: One Conversion Event**\
If you have your Campaign Goal set up to track one conversion event, the following tracking logic will take place:

* If a referral, a referral will be automatically created and set to Confirmed in the correct campaign.
* If not a referral, a non-referred subscriber will be created in the campaign UUID specified.
* If the subscriber exists in our database, the subscriber will be 'identified'. Data is not overwritten. Additional data will be created.
  {% endhint %}

{% hint style="info" %}
**GOAL: Two or Three Conversion Events**\
If you have your Campaign Goal set up to track two or three conversion events, the following tracking logic will take place:

* If a referral, a referral will be created and set to Pending in the correct campaign.
* If not a referral, a non-referred subscriber will be created in the campaign UUID specified.
* If the subscriber exists in our database, the subscriber will be 'identified'. Data is not overwritten.
  {% endhint %}

**Parameters**

| <p><strong>referralParams</strong> </p><p>RHSubscriber </p>       | Carrying the user data to be updated.                                             |
| ----------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution; else NULL |

Step 1. ReferralParams Model

<table><thead><tr><th width="345"></th><th></th></tr></thead><tbody><tr><td><strong>Method</strong></td><td><strong>Description</strong></td></tr><tr><td>transaction_id (String)</td><td>The unique ID of the transaction. Useful for tracking referrals for purchases.</td></tr><tr><td>conversion_category (String)</td><td>The type of referral. Useful for creating reports.</td></tr><tr><td>conversion_value (String)</td><td>The monetary value of the referral.</td></tr><tr><td>device (String value)</td><td>The device used by the subscriber to sign up. Used for analytics.</td></tr><tr><td>email (String value)</td><td>The email of the subscriber.</td></tr><tr><td>domain (String)</td><td>The URL for the referral link.</td></tr><tr><td>name (String)</td><td>The name of the subscriber.</td></tr><tr><td>referrer (String)</td><td>Set a referrer for the subscriber by providing the referrer's referral code or email.</td></tr><tr><td>source (String)</td><td>The source of the subscriber. Used for analytics.</td></tr><tr><td>crypto_wallet_address (String)</td><td>The crypto wallet address</td></tr><tr><td>extra_field (String)</td><td>The extra field of the subscriber.</td></tr><tr><td>extra_field2 (String)</td><td>The extra field 2 of the subscriber.</td></tr><tr><td>points (String)</td><td>The number of points for the subscriber. Only applicable for "contest" campaigns.</td></tr><tr><td>phone_number (String)</td><td>The Phone Number of subscriber</td></tr><tr><td>double_optin (string value)</td><td>If set to false, the subscriber will not receive a confirmation email.</td></tr><tr><td>status (String)</td><td>Use 'custom_event_pending' to set the referral status to pending</td></tr></tbody></table>

Step2.

Create a ReferralParams class object and set the various user details to identify the user matching your back-end system.

{% tabs %}
{% tab title="Java" %}

```java
ReferralParams referralParams = new ReferralParams();
referralParams.setEmail(signup_email?.editText?.text.toString());//Required value, capture this from user
referralParams.setDomain("https://a.domain.co/");//Required value, should match the default referral link set within your RH account
referralParams.setName(Username?.editText?.text.toString());//Optional but recommended, capture this from user
referralParams.setUuid("MFxxxxxxxxxx");//Get this from within your RH account
referralParams.setReferrer(EditText?.getText().toString());//Optional value, only necessary if the user will provide the referrer code directly, otherwise the below 4 params are required
referralParams.setIpAddress(rh.deviceInfo.getIpAddress());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setOperatingSystem(rh.deviceInfo.getOperatingSystem());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setDevice(rh?.deviceInfo?.getDeviceType());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setScreenSize(rh.deviceInfo.getDeviceScreenSize());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setStatus("custom_event_pending");//Use 'custom_event_pending' to set the referral status to pending
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val referralParams = ReferralParams()
referralParams.email = signup_email?.editText?.text.toString()//Required value, capture this from user
referralParams.domain = "https://a.domain.co/"//Required value, should match the default referral link set within your RH account
referralParams.name = Username?.editText?.text.toString()//Optional but recommended, capture this from user
referralParams.uuid = "MFxxxxxxxxxx"//Get this from within your RH account
referralParams.referrer = referralcode?.editText?.text.toString().trim { it <= ' ' }//Optional value, only necessary if the user will provide the referrer code directly, otherwise the below 4 params are required 
referralParams.device = rh?.deviceInfo?.getDeviceType()//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.ipAddress = rh?.deviceInfo?.getIpAddress()//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.osType = rh?.deviceInfo?.getOperatingSystem()//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.screenSize = transformResolution(rh?.deviceInfo?.getDeviceScreenSize())//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.status = "custom_event_pending"//Use 'custom_event_pending' to set the referral status to pending
```

{% endtab %}
{% endtabs %}

**To add a subscriber** (for example, post a successful signup or login) call ReferralHero's rh.formSubmit() function and send the ReferralParams information such as email address and name. The minimum values you should send for the endpoint to work are the following:

```java
referralParams.setEmail("johnDoe123@gmail.com") 
referralParams.setDomain("https://a.domain.co/"); 
```

**To identify and create a referral**, you must also send either the setReferrer OR the required mobile params so that our matching algorithm can automatically identify a referral.

```json
// Example Data
“os_type”: “Android”,
“device”: “Android”,
“ip_address”: “123.156.219.010",
“screen_size”: “432.0 x 960.0",
```

{% hint style="warning" %}
NOTE:\
The mobile parameters must be sent in the correct format for our system to automatically identify and create a referral. See the Getting Started section [here](/integrate/mobile-sdks/ios-sdk/getting-started.md#tracking-referrals).
{% endhint %}

The accepted Screen Size formats are:

```kotlin
referralParams.setScreenSize("393*852")
referralParams.setScreenSize("393 x 852")
referralParams.setScreenSize("393x852")
referralParams.setScreenSize("393.0 x 852.0")
// in case you need to hard code values
```

See here for more parameters of [ReferralParams](/integrate/mobile-sdks/android-sdk/public-classes.md) Class.

#### Step 3.&#x20;

Invoke `rh.formSubmit`(**RHReferralCallBackListener** *callback*, **ReferralParams** *referralparams* ) method of the RH class to Add Subscriber API calls, passing the ReferralParams object created in the previous step and an *RHReferralCallBackListener* instance.

It is advised that you INITIALIZE the SDK in the Application class, so that we may ensure a smooth user experience check out this [SDK initialize steps](/integrate/mobile-sdks/android-sdk/getting-started.md#setup-sdk).

Use the following code to Add Subscriber:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance()
rh.formSubmit(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
}, referralParams);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance();
rh?.formSubmit(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
}, referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 2. Add Pending Referral

This method is most commonly used to create a referral entering the 1st step of your multi-step conversion event funnel (i.e. after a referred user successfully signs up for your app). If you want us to automatically add every user to your campaign and determine if the user is a referral or not, use the Add Subscriber method instead. This logic only checks for referrals:

{% hint style="info" %}
**Tracking Logic**

**GOAL: Two or Three Conversion Events**

Your campaign Goal must be set up to track two or three conversion events, and then the following tracking logic will take place:

* If a referral, a referral will be automatically created and set to Pending in the correct campaign.
* If not a referral, no subscriber will be created.&#x20;
  {% endhint %}

To add a pending referral, simply call ReferralHero's RH.pendingReferral() function and send the user information such as email address, name, etc.

**Parameters**

| <p><strong>referralParams</strong> </p><p>ReferralParams </p>     | Carrying the referral data.                                                        |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |

**Step 1.**&#x20;

Create a **ReferralParams** class object and set the various user details to identify the user matching your back-end system.

{% tabs %}
{% tab title="Java" %}

```java
ReferralParams referralParams = new ReferralParams();
referralParams.setEmail(signup_email.editText.getText().toString()); //Capture this from user)
referralParams.setName(Username.editText.getText().toString());
referralParams.setReferrer(EditText?.getText().toString());//Optional value, only necessary if the user will provide the referrer code directly, otherwise the below 4 params are required
referralParams.setIpAddress(rh.deviceInfo.getIpAddress());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setOperatingSystem(rh.deviceInfo.getOperatingSystem());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setDevice(rh?.deviceInfo?.getDeviceType());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
referralParams.setScreenSize(rh.deviceInfo.getDeviceScreenSize());//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val referralParams = ReferralParams()
referralParams.email = signup_email?.editText?.text.toString() //Required value, capture this from user
referralParams.name = Username?.editText?.text.toString() //Optional but recommended, capture this from user
referralParams.referrer = referralcode?.editText?.text.toString().trim { it <= ' ' } //Optional value, only necessary if the user will provide the referrer code directly, otherwise the below 4 pramas are required 
referralParams.device = rh?.deviceInfo?.getDeviceType()//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer pramas
referralParams.ip_address = rh?.deviceInfo?.getIpAddress()//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer pramas
referralParams.os_type = rh?.deviceInfo?.getOperatingSystem()//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer pramas
referralParams.screen_size = transformResolution(rh?.deviceInfo?.getDeviceScreenSize())//Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer pramas
```

{% endtab %}
{% endtabs %}

To add a pending referral, simply call ReferralHero's `rh.pendingReferral()` function and send the ReferralParams data.

The minimum values for this endpoint to work:

```java
referralParams.setEmail(signup_email.editText.getText().toString()); 
referralParams.setReferrer("M12345fc2");
```

OR:

```java
referralParams.setEmail(signup_email.editText.getText().toString()); 
referralParams.setIpAddress(rh.deviceInfo.getIpAddress());
referralParams.setOperatingSystem(rh.deviceInfo.getOperatingSystem());
referralParams.setDevice(rh?.deviceInfo?.getDeviceType());
referralParams.setScreenSize(rh.deviceInfo.getDeviceScreenSize());
```

{% hint style="info" %}
NOTE:\
The mobile parameters must be sent in the correct format for our system to automatically identify and create a referral. See the Getting Started section [here](/integrate/mobile-sdks/ios-sdk/getting-started.md#tracking-referrals).
{% endhint %}

**Step 2.**

Invoke `rh.pendingReferral`(**RHReferralCallBackListener** *callback*, **ReferralParams** *referralparams*) method of the *RH* class to Add Subscriber API calls, passing the *ReferralParams* object created in the previous step and an *RHReferralCallBackListener* instance.

Use the following code to Add Pending Referral:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance()
rh.pendingReferral(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
}, referralParams);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance();
rh?.pendingReferral(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
}, referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 3. Track Referral

This method is used for tracking a referral conversion event (i.e. a purchase, but can be any conversion event).&#x20;

{% hint style="info" %}
**Tracking Logic**:

* If a referral and pre-existing in the campaign as Pending

**OR**

* If a referral and setReferrer or mobile params are provided, a referral is automatically created in the correct campaign and

**The Referral Is Set To:**

* Confirmed (if tracking two conversion events)
* Unconfirmed (if tracking three conversion events)
  {% endhint %}

Note:

1. Your campaign must be set up as a custom event or a multi-step event otherwise, an error will return.
2. If the referral is present in ReferralHero with pending status, a successful response `custom_event_completed` will return.
3. If the referral unique identifier is not present in the ReferralHero, but the referrer unique identifier is present, a successful response `custom_event_completed` with the data of the new confirmed referral will return.
4. If a referral exists but the referral status is not pending, the error `custom event is already completed` will return.
5. If the referral unique identifier is not present in ReferralHero and the referrer is also not provided in the API, the error `referer is invalid or not present` will return.
6. If the referral status is unconfirmed or confirmed, the error `custom event is already completed` and will return.

{% hint style="warning" %}
When tracking referrals on your App you should ALWAYS send the ACTUAL unique identifier (email, phone number, crypto wallet address, or other ID) of the user in referralParams class Object.
{% endhint %}

**Parameters**

| <p><strong>referralParams</strong> </p><p>ReferralParams </p>     | Carrying the user data to be updated.                                              |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |

**Step 1.**&#x20;

Create a **ReferralParams** class object and set the various user details to identify the user matching your back-end system.

{% tabs %}
{% tab title="Java" %}

```java
ReferralParams referralParams = new ReferralParams();
referralParams.setEmail(signup_email.editText.getText().toString()); //Required value, capture this from user
referralParams.setName(Username.editText.getText().toString()); //Optional value, capture this from user
referralParams.setReferrer("M12345fc2"); //Optional value, only required if the user does not exist in the campaign
referralParams.setIpAddress(rh.deviceInfo.getIpAddress());//Optional value, only required if the user does not exist in the campaign
referralParams.setOperatingSystem(rh.deviceInfo.getOperatingSystem());//Optional value, only required if the user does not exist in the campaign
referralParams.setDevice(rh?.deviceInfo?.getDeviceType());//Optional value, only required if the user does not exist in the campaign
referralParams.setScreenSize(rh.deviceInfo.getDeviceScreenSize());//Optional value, only required if the user does not exist in the campaign
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val referralParams = ReferralParams()
referralParams.email = signup_email?.editText?.text.toString() //Required value, capture this from user
referralParams.name = Username?.editText?.text.toString() //Optional value, capture this from user
referralParams.referrer = "M12345fc2" //Optional value, only required if the user does not exist in the campaign
referralParams.device = rh?.deviceInfo?.getDeviceType()//Optional value, only required if the user does not exist in the campaign
referralParams.ipAddress = rh?.deviceInfo?.getIpAddress()//Optional value, only required if the user does not exist in the campaign
referralParams.osType = rh?.deviceInfo?.getOperatingSystem()//Optional value, only required if the user does not exist in the campaign
referralParams.screenSize = transformResolution(rh?.deviceInfo?.getDeviceScreenSize())//Optional value, only required if the user does not exist in the campaign
```

{% endtab %}
{% endtabs %}

**If the referral is pre-existing in the campaign**, the minimum value for this endpoint to work:

```java
referralParams.setEmail(signup_email.editText.getText().toString());
```

{% hint style="info" %}
**If the referral is NOT pre-existing in the campaign** (and you want to identify and create a referral), you must send either the setReferrer OR the required mobile parameters in the correct format so that our matching algorithm can automatically identify a referral. See the Getting Started section [here](/integrate/mobile-sdks/ios-sdk/getting-started.md#tracking-referrals).
{% endhint %}

**Step 2.**&#x20;

Call  `rh.trackReferral`(**RHReferralCallBackListener** *callback*, **ReferralParams** *referralparams* ) method of the RH class to Add Subscriber API calls, passing the *ReferralParams* object created in the previous step and an *RHReferralCallBackListener* instance.

Use the following code to Track Referral:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.trackReferral(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
}, referralParams);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.trackReferral(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
},referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 4. Confirm Referral

Use this method when your Campaign Goal is set to track three conversion events and you want to confirm a referral when your third conversion event occurs (complete profile, upgrade to a paid plan, end of the trial, etc).

{% hint style="info" %}
**Tracking Logic**:

* If a referral and pre-existing in the campaign as Unconfirmed

**The Referral Is Set To:**

* Confirmed (if tracking three conversion events)
  {% endhint %}

Note: Only verified referrals can be confirmed. Trying to confirm a non-verified referral will return a `subscriber_not_found` error.

**Parameters**

| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

**Step 1.**

Invoke `rh.confirmReferral`(**RHReferralCallBackListener** *callback*) method of the *RH* class to Confirm Subscriber API calls, passing an *RHReferralCallBackListener* instance.

Use the following code to Confirm Referral:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.confirmReferral(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.confirmReferral(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
}, referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 5. Organic Track Referral

If you would like to add a non-referred subscriber or a track referral on the conversion page to your referral campaign, you can use the following method. This method would most commonly be used if the **user has not been previously added to your campaign** and instead directly passes through a post-checkout/subscribe event.

{% hint style="info" %}
**Tracking Logic**:

* If a referral and pre-existing in the campaign as Pending

**OR**

* If a referral and setReferrer or mobile params are provided, a referral is automatically created in the correct campaign and

**The Referral Is Set To:**

* Confirmed (if tracking two conversion events)
* Unconfirmed (if tracking three conversion events)

**OR**

* If not a referral, a non-referred subscriber is created in the campaign UUID specified.
  {% endhint %}

**Parameters**

| <p><strong>referralParams</strong> </p><p>ReferralParams </p>     | Carrying the referral data.                                                        |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |

**Step 1.**&#x20;

Create a [ReferralParams ](https://docs.google.com/document/d/1pTU0vB9RKZ5_us-ycdFVJFb4TvYuOKuPRVFjQu8cVv0/edit#heading=h.dlqm64495bqt)class object and set the various user details to identify the user matching your back-end system.

{% tabs %}
{% tab title="Java" %}

```java
ReferralParams referralParams = new ReferralParams();
referralParams.setEmail(signup_email.editText.getText().toString()) //Capture this from user);
referralParams.setName(Username.editText.getText().toString()); //Capture this from user
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val referralParams = ReferralParams()
referralParams.email = signup_email?.editText?.text.toString() //Capture this from user
referralParams.name = Username?.editText?.text.toString() //Capture this from user
```

{% endtab %}
{% endtabs %}

To add an organic referral track, simply call ReferralHero's `rh.organicTrackReferral()` function and send the ReferralParams information such as email address and name.

{% hint style="info" %}
**If the referral is NOT pre-existing in the campaign** (and you want to identify and create a referral), you must send either the setReferrer OR the required mobile parameters in the correct format so that our matching algorithm can automatically identify a referral. See the Getting Started section [here](/integrate/mobile-sdks/ios-sdk/getting-started.md#tracking-referrals).
{% endhint %}

**Step 2.**

Invoke `rh.organicTrackReferral`(**RHReferralCallBackListener** *callback*, **ReferralParams** *referralparams*) method of the *RH* class to Add Subscriber API calls, passing the *ReferralParams* object created in the previous step and an *RHReferralCallBackListener* instance.

Use the following code for Organic Track Referral:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.organicTrackReferral(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
}, referralParams)
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.organicTrackReferral(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
}, referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 6. Update Subscriber Details

This method is used to update various subscriber data like username, address, etc.

First create a ReferralParams class instance and set the user data you want to update using its setter methods, then pass that instance in this method.

**Parameters**

| <p><strong>referralParams</strong> </p><p>ReferralParams </p>     | Carrying the user data to be updated.                                              |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |

**Step 1.**&#x20;

[Follow this step](https://support.referralhero.com/integrate/mobile-sdks/android-sdk/pages/GZJJrLJNduPBfVtFmawZ#1.-add-subscriber-manually) (Add a Subscriber - previously described)

**Step 2.**&#x20;

Call  `rh.updateSubscriber`(**RHReferralCallBackListener** *callback*, **ReferralParams** *referralparams* ) method of the RH class to Add Subscriber API calls, passing the *ReferralParams* object created in the previous step and an *RHReferralCallBackListener* instance.

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.updateSubscriber(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
}, referralParams);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.updateSubscriber(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
}, referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 7. Get Subscriber Details

This method is used to retrieve subscriber details.

**Parameters**

| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

**Step 1.**&#x20;

Call `rh.getSubscriber`(**RHReferralCallBackListener** *callback*) method of the RH class to get Subscriber API calls, passing the *RHReferralCallBackListener* instance.

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.getSubscriber(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

<pre class="language-kotlin"><code class="lang-kotlin">val rh =  RH.getInstance()
<strong>rh?.getSubscriber(object : RH.RHReferralCallBackListener {
</strong>   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
})
</code></pre>

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 8. Delete Subscriber

This method is used to delete a created subscriber.

**Parameters**

| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

#### Step 1.&#x20;

Call  `rh.deleteSubscriber`(**RHReferralCallBackListener** *callback*) method of the RH class to get Subscriber API calls, passing the *RHReferralCallBackListener* instance.

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.deleteSubscriber(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.deleteSubscriber(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
})
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 9. Capture Share

This method is used to send a user share event to ReferralHero. When this method is called including the params (i.e. facebook, messenger, etc.), we capture a share in our analytics system.

**Parameters**

| <p><strong>referralParams</strong> </p><p>ReferralParams </p>     | Carrying the user data to be updated.                                              |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |

**Step 1.**&#x20;

Call  `rh.captureShare`(**RHReferralCallBackListener** *callback*, **ReferralParams** *referralparams* ) method of the *RH* class to Add Subscriber API calls, passing the *ReferralParams* object created in the previous step and an *RHReferralCallBackListener* instance.

Use the following code to Capture Share:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.captureShare(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
}, referralParams);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.captureShare(object : RH.RHReferralCallBackListener {
   override fun onSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onFailureCallback(response: String?) {
       //on failure put your logic here
   }
},referralParams)
```

{% endtab %}

{% tab title="responseData" %}
Subscriber Data Class Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_8645f85ac894",
        "name": "Test User 10",
        "email": "test10@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "3ab0f674",
        "position": 10,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684403108,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}
```

{% endtab %}
{% endtabs %}

### 10. Get My Referrals

This method is used for retrieving all referrals of the specific subscriber.

**Parameters**

| <p><strong>callback</strong></p><p>RHMyReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

Step 1.&#x20;

Call  `rh.getMyReferrals`(**RHMyReferralCallBackListener** *callback*) method of the *RH* class to get Subscriber API calls, passing the *RHReferralCallBackListener* instance.

Use the following code to Get My Referrals:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.getMyReferrals(new RH.RHMyReferralCallBackListener() {
   @Override
   public void onMyReferralSuccessCallback(@Nullable String response) {
       //on success put your logic here
   }

   @Override
   public void onMyReferralFailureCallback(@Nullable String response) {
     //on failure put your logic here
   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance();
rh?.getMyReferrals(object : RH.RHMyReferralCallBackListener {
   override fun onMyReferralSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onMyReferralFailureCallback(response: String?) {
       //on failure put your logic here
   }
})
```

{% endtab %}

{% tab title="responseData" %}
Get My Referral Sample Response

```kotlin
{
  "status": "ok",
  "data": {
    "response": "subscribers_retrieved",
    "subscribers": [
      {
        "id": "sub_fa49ba0d30e9",
        "name": "Test User 10",
        "email": "test125@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "dededb46",
        "position": 20,
        "referred": true,
        "referred_by": {
          "id": "sub_d0cc231dce89",
          "name": "Test name",
          "email": "test26@gmail.com",
          "code": "0879561f",
          "people_referred": 1,
          "points": 0
        },
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684985427,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=dededb46",
        "created_at": 1684985427,
        "last_updated_at": 1684985427
      }
    ],
    "pagination": {
      "total_pages": 1,
      "current_page": 1,
      "per_page": 50,
      "total_objects": 1
    }
  },
  "calls_left": null,
  "timestamp": 1685012334
}
```

{% endtab %}
{% endtabs %}

### 11. Get Leaderboard

This method is used for retrieving the leaderboard from the campaign UUID set in the `AndroidManifest.xml` file.

**Parameters**

| <p><strong>callback</strong></p><p>RHLeaderboardReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

**Step 1.**&#x20;

Call  `rh.getLeaderboard`(**RHLeaderboardReferralCallBackListener** *callback*) method of the *RH* class to get Subscriber API calls, passing the *RHLeaderboardReferralCallBackListener* instance.

Use the following code to Get Leaderboard:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
rh.getLeaderboard(new RH.RHLeaderboardReferralCallBackListener() {
   @Override
   public void onLeaderboardReferralSuccessCallback(@Nullable String response) {
      
   }

   @Override
   public void onLeaderboardReferralFailureCallback(@Nullable String response) {

   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.getLeaderboard(object : RH.RHLeaderboardReferralCallBackListener {
   override fun onLeaderboardReferralSuccessCallback(response: String?) {
       //on success put your logic here
   }

   override fun onLeaderboardReferralFailureCallback(response: String?) {
       //on failure put your logic here
   }
})
```

{% endtab %}

{% tab title="responseData" %}
Get Leaderboard Sample Response

```kotlin
{
  "status": "ok",
  "data": {
    "ranking": [
      {
        "id": "sub_7b9be1ed8ccb",
        "name": "Test User 10",
        "email": "test15@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "2c2dbefb",
        "position": 1,
        "referred": false,
        "referred_by": {
          
        },
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1685018462,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=2c2dbefb",
        "created_at": 1685018462,
        "last_updated_at": 1685020506
      },
      {
        "id": "sub_06e2af5a2236",
        "name": "Test User multi1",
        "email": "testorganic3@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "afd54225",
        "position": 2,
        "referred": false,
        "referred_by": {
          
        },
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1685018562,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "status":"",
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=afd54225",
        "created_at": 1685018562,
        "last_updated_at": 1685018562
      }
    ],
    "count": 2
  },
  "calls_left": null,
  "timestamp": 1685020750
}
```

{% endtab %}
{% endtabs %}

### 12. Get Referrer

This method is used to retrieve the referrer of a user. By calling this method, you would know if someone was a referral or not, and then could:

* Apply a discount code automatically to the checkout process
* Personalize text shown on a page

**Parameters**

| <p><strong>callback</strong></p><p>RHReferralCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

**Step 1.**&#x20;

Create a [ReferralParams ](https://docs.google.com/document/d/1pTU0vB9RKZ5_us-ycdFVJFb4TvYuOKuPRVFjQu8cVv0/edit#heading=h.dlqm64495bqt)class object and set the various user details to identify the user matching your back-end system.

{% tabs %}
{% tab title="Java" %}

```java
ReferralParams referralParams = new ReferralParams();
referralParams.setEmail(signup_email.editText.getText().toString()) //Capture this from user);
referralParams.setName(Username.editText.getText().toString()); //Capture this from user);
referralParams.setIpAddress(rh.deviceInfo.getIpAddress());
referralParams.setOperatingSystem(rh.deviceInfo.getOperatingSystem());
referralParams.setDevice(rh?.deviceInfo?.getDeviceType());
referralParams.setScreenSize(rh.deviceInfo.getDeviceScreenSize());
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val referralParams = ReferralParams()
referralParams.email = signup_email?.editText?.text.toString() //Capture this from user
referralParams.name = Username?.editText?.text.toString() //Capture this from user
referralParams.IpAddress = rh.deviceInfo.getIpAddress()
referralParams.operatingSystem = rh.deviceInfo.getOperatingSystem()
referralParams.device = rh?.deviceInfo?.getDeviceType()
referralParams.setScreenSize = rh.deviceInfo.getDeviceScreenSize()
```

{% endtab %}
{% endtabs %}

Minimum parameters for this endpoint to work:

```java
referralParams.setEmail(signup_email.editText.getText().toString());
referralParams.setIpAddress(rh.deviceInfo.getIpAddress());
referralParams.setOperatingSystem(rh.deviceInfo.getOperatingSystem());
referralParams.setDevice(rh?.deviceInfo?.getDeviceType());
referralParams.setScreenSize(rh.deviceInfo.getDeviceScreenSize());
```

{% hint style="warning" %}
NOTE:

The mobile parameters must be sent in the correct format for our system to automatically identify a referral. See the Getting Started section [here](/integrate/mobile-sdks/ios-sdk/getting-started.md#tracking-referrals).
{% endhint %}

**Step 2.**&#x20;

Invoke `rh.getReferrer`(**RHReferralCallBackListener** *callback*) method of the *RH* class to get referrer Subscriber data  API calls, passing an *RHReferralCallBackListener* instance.

Use the following code to Get Referrer data:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
RH.getInstance().getReferrer(new RH.RHReferralCallBackListener() {
   @Override
   public void onSuccessCallback(@Nullable String apiResponse) {
      //success
   }

   @Override
   public void onFailureCallback(@Nullable String apiResponse) {
      // fail       
   }
});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.instance?.getReferrer(object : RHReferralCallBackListener {
   override fun onSuccessCallback(apiResponse: String?) {
       //success
   }

   override fun onFailureCallback(apiResponse: String?) {
       //fail
   }
})
```

{% endtab %}

{% tab title="responseData" %}
Get Referrer Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "id": "sub_68c9ed9e2712",
        "name": "test one",
        "email": "test1@gmail.com",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0.0,
        "code": "00598133",
        "position": 2,
        "referred": false,
        "referred_by": {},
        "people_referred": 1,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1686310876,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com?mwr=00598133",
        "created_at": 1686310876,
        "last_updated_at": 1686311874,
        "os_type": null,
        "screen_size": null,
        "ip_address": null,
        "universal_link": "https://app.referralhero.com/MFxxxxxxxxx/universal_link?mwr=00598133",
        "status": "",
        "response": "subscriber_retrieved"
    },
    "calls_left": null,
    "timestamp": 1690439303
}
```

{% endtab %}
{% endtabs %}

### 13. Get Rewards

Use this method to Get Rewards unlocked by a specific subscriber.

**Parameters**

| <p><strong>callback</strong></p><p>RHRewardCallBackListener</p> | Callback interface if you want to get the callback after API execution ; else NULL |
| --------------------------------------------------------------- | ---------------------------------------------------------------------------------- |

**Step 1.**

Invoke `rh.getRewards`(**RHRewardCallBackListener** *callback*) method of the *RH* class to get all rewards list data  API calls, passing an *RHRewardCallBackListener* instance.

Use the following code to Get Rewards data:

{% tabs %}
{% tab title="Java" %}

```java
RH rh =  RH.getInstance();
RH.getInstance().getRewards(new RH.RHRewardCallBackListener() {
   @Override
   public void onRewardSuccessCallback(@Nullable String apiResponse) {
          }
@Override
public void onRewardFailureCallback(@Nullable StringapiResponse) {
   }


});
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val rh =  RH.getInstance()
rh?.instance?.getRewards(object : RHRewardCallBackListener{
   override fun onRewardSuccessCallback(apiResponse: String?) {
       //success
   }

   override fun onRewardFailureCallback(apiResponse: String?) {
       //fail
   }
})
```

{% endtab %}

{% tab title="responseData" %}
Get Rewards Sample Response

```kotlin
{
    "status": "ok",
    "data": {
        "response": "rewards_retrieved",
        "rewards": [
            {
                "id": 1795,
                "name": "A free Premium account for 1 year",
                "status": "confirmed",
                "referrals": null,
                "created_at": 1686397951,
                "signup_type": "organic subscriber",
                "referrals_type": null,
                "recurring_count": null,
                "image_url": null
            }
        ],
        "pagination": {
            "total_pages": 1,
            "current_page": 1,
            "per_page": 10,
            "total_objects": 1
        }
    },
    "calls_left": null,
    "timestamp": 1687759997
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.referralhero.com/integrate/mobile-sdks/android-sdk/public-methods.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
