API Interaction Methods

ReferralHero iOS Swift SDK

Here is a description of Each Method of the class API_HELPER in order to get access to all information provided by the SDK.

A whole set of public methods exists within the SDK using which you can easily access most of the data.

formSubmit(param: RHSubscriber)

Submits a form to create a new subscriber.

getSubscriberDetail()`

Fetches details for a subscriber.

DeleteSubscriber()

Deletes a subscriber

UpdateSubscriber(param: RHSubscriber)

Updates subscriber details.

clickCapture(social: String)

Captures a click action for a specified social media

getMyReferrals()

Retrieves referral data for the subscriber

getLeaderboard()

Fetches the leaderboard data

trackReferral(param: RHTrackReferral)

Tracks a referral event

ConfirmReferral()

Confirms a referral

OrganicTrackReferral(param: RHOrganicReferral)

Tracks an organic referral event

CreatePendingReferral(param: RHReferral)

Creates a pending referral

RewardsList()

Retrieves a list of rewards

ReferrerList()

Fetches a list of referrers based on specific parameters

Logout()

Logs out the current user and clears stored data

1. Add Subscriber

Setting/Updating the ReferralParams details is an important step. This is how ReferralHero would be aware of the identity of a business user as classified by your app.

To add a subscriber (for example, post a successful signup or login) simply call ReferralHero's RH.formSubmit() function and send the RHSubscriber information such as email address and name.

func formSubmit()
    {
        RH.formSubmit(param: RHSubscriber(email: "xyz@gmail.com", domain: "www.abc.com", name: “ABC"))
    }

NOTE:

The parameters need to be sent in the correct order for our system to automatically generate a referral.

2. Update Subscriber Details

This method is used to update various user related data.

First, create a RHSubscriber model and set the user data you want to update.

To update the subscriber simply call ReferralHero's RH.UpdateSubscriber() function and send the RHSubscriber information such as email address and name.

  RH.UpdateSubscriber(param: RHSubscriber(email:    "abc@gmail.com", domain: "www.xyz.com", name: "abc"))

3. Get Subscriber Details

This method is used to retrieve Subscriber details. RH.getSubscriberDetail()

  RH.getSubscriberDetail()

4. Delete Subscriber

This method is used to Delete a newly Created Subscriber.

To update the subscriber call ReferralHero's RH.DeleteSubscriber().

  RH.DeleteSubscriber()

5. Track Referral

This method is used to track the referral conversion event. It means it is used to convert Referral status from pending to unconfirmed/confirmed.

If the referrer is present in the API request params, we will check the referral unique identifier in your campaign and, if found, the referral status will be updated and, if not found, we will create the referral and set the referral status.

If the referrer is not present in the API request params, we will check the referral unique identifier in your campaign and, if found, the referral status will be updated and, if not found, the referral will not be created.

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 will return.

  • uniqueIdentifier is a placeholder.

  • 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 RHSubscriber class Object

Call RH.trackReferral(RHTrackReferral referralparams ). Use the following code to Track referral:

RH.trackReferral(param: RHTrackReferral(email: "xyz@gmail.com", name:"xyz"))

6. Capture Share

Step 1. Method Usage

This method is used to send the Share event to the RH. It means if a user called this method with any params like Facebook, messenger, etc. We capture this as a share in our system.

Call the RH.clickCapture method of the RH class and pass “social” as an input parameter. Use the following code to Capture Share for a user:

RH.clickCapture(social: "facebook")

7. Get My Referrals

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

Call RH.getMyReferrals() method of the RH class

Use the following code to Get My Referrals:

RH.getMyReferrals()

8. Get Leaderboard

This method is used for retrieving the campaign leaderboard. It will get the leaderboard from the Campaign specified in the Appdelegate.swift file.

Step 1. Input Parameters

Call the RH.getLeaderboard() method of the RH class to get the Subscriber Leaderboard.

RH.getLeaderboard()

9. Create Pending Referral

This method is used for creating a Referral with the Pending Status.

Create a ReferralParams class object and set the various user details to recognize the user matching your back-end system. To add a pending referral, simply call ReferralHero's RH.CreatePendingReferral() function and send the ReferralParams information such as email address and name.

RH.CreatePendingReferral(param: RHReferral(email: "xyz@gmail.com", name: "XYZ"))

10. Organic Track Referral

If you would like to track referrals or add organic subscribers on the conversion page to your referral campaign, you can use this method.

If the Referrer code and uniqueidentifier are present, a Referral is created with the status unconfirmed/confirmed referral on the basis of the ‘Review Referral’ feature enabled/disabled.

If the Referrer code is not present but uniqueidentifier is present, an Organic Subscriber is created.

If the Referrer code is not present but a uniqueidentifier is present and a Referral already exists with the same uniqueidentifier in the campaign with pending status, the Referral Status will convert from pending to unconfirmed/confirmed on the basis of the ‘Review Referral’ feature enabled/disabled.

Create a RHOrganicReferral model and set the various user details to recognize the user matching your back-end system.

RH.OrganicTrackReferral(param: RHOrganicReferral(email: "abc@gmail.com", name: "ABC"))

11. Confirm Referral

Confirm a referral. Useful when your campaign Goal is set to a "3-step conversion event" option and you want to confirm referrals when they complete your 3rd conversion event.

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

Call the RH.ConfrimReferral method of the RH class.

RH.ConfirmReferral()

12. Get Referrer

Call the RH.ReferrerList method of the RH class. Use the following code to get the referrer:

RH.ReferrerList()

13. Get Rewards

Call the RH.RewardsList method of the RH class. Use the following code to get the rewards:

RH.RewardsList()

Last updated