React SDK

1. Add Invitereferrals Library to your Project

npm install react-native-invitereferrals

2. Link library to Project

react-native link react-native-invitereferrals

3. Initialize Sdk

A. Configure your AndroidManifest.xml

<manifest….>
            <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
            <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
            <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
            <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
            <uses-permission android:name="android.permission.GET_TASKS" />
            <uses-permission android:name="android.permission.WAKE_LOCK" />
    
            <application>
                     
                <meta-data android:name="invitereferrals_bid" android:value="17xx"></meta-data> 
              <meta-data android:name="invitereferrals_bid_e" android:value="B0xx"></meta-data>
               
            </application>
    </manifest>

📘

Note:

In the above example, Dummy Brand ID and Encryption keys shown. Kindly login your IR_account to see your credentials.

  • If you want to use contact_sync feature, then add the following permissions into your
    manifest.xml file under manifest tag.
<uses-permission android:name="android.permission.READ_CONTACTS" />
       <uses-permission android:name="android.permission.WRITE_CONTACTS" />

B. MainApplication class initialization

  • Import library as shown below.
import com.invitereferrals.invitereferrals.InvitereferralsModule;
  • Call this method in onCreate() function.\
InvitereferralsModule.register(this); 
          // Example:   
             @Override
             public void onCreate() {
                    super.onCreate();
                Log.e("MainApplication","onCreate");
                  InvitereferralsModule.register(this);
                Loader.init(this, /* native exopackage */ false);
             }

Plugin Methods (react integration)

  • To use plugin functions import module on your react page.
import Invitereferrals from 'react-native-invitereferrals';

Add Referral Button

  • Add the following line in your custom button click. Replace CampaignID with the id of the referral campaign. Default campaignID will be applied if no campaignID specified.
Invitereferrals.inline_btn(“campaignID” );

// Example:-
//      Invitereferrals.inline_btn(“1765”);

📘

Note:

  • For​ ​Default​ ​Campaign​ ​you​ ​can​ ​pass​ ​0​ ​as​ ​CampaignID:
    Invitereferrals.inline_btn(“0”);

Pass User Details for Auto-Login (Single Sign In)

Invitereferrals.userDetails((String)name, (String)email, (String)mobile, (String)campaignID, (String)subscriptionID, (String)customValues, callback);
// Example:
//      Invitereferrals.userDetails("abc", "[email protected]", "9876543210", “0”, null, null, this.successCallback  );

📘

Callback function be like this:

successCallback(msg){
alert(“success msg= ”+ msg);
}

Tracking Install / Register / Sale Events

  • You call tracking() method to track events (i.e. install , register or sale):

Install

invitereferrals.tracking(“install”,null,”0”, null, null);

Register

invitereferrals.tracking(“register”,(String)EMAIL_ID,(String)PURCHASE_VALUE, null, null, successCallback, errorCallback);
// Example:
//  invitereferrals.tracking(“register”,”[email protected]”,”0”, null,        null, this.funSuccess, this.funError);

📘

Success and Error Callback

funSuccess(msg){
alert(“success msg = ”+msg);
}
funError(msg){
alert(“error msg = ”+msg);
}

Sale

invitereferrals.tracking(“sale”,(String)ORDER_ID,(String)PURCHASE_VALUE, null, null, successCallback,  errorCallback);
// Example:
//      invitereferrals.tracking(“sale”,“abc123”,“99”, null, null,this.funSuccess, this.funError);

Show Welcome Message

  • Show​ ​welcome​ ​message​ ​to​ ​customer​ ​if​ ​he​ ​comes​ ​through​ ​referral​ ​of​ ​his​ ​friend.
Invitereferrals.showWelcomeMessage();

Show Refer a friend Popup

  • Just add the following line in the activity in which you want to show the referral program popup
Invitereferrals.invite((String)showRule);
// Example: 
//      Invitereferrals.invite("home");