ReferralHero
  • Welcome to the Support Center
  • Common Questions
  • Features
    • Subscribers
      • Subscriber Profile
      • Unique Identifier
      • Active Visitors
      • 'Quick Add' Referral
      • Update Referral Status
    • Campaign Templates
      • Contest
      • Website Referral Analysis
      • Net Promoter Score
    • Unique Identifier
      • Phone Number
      • Confirmation Email
        • Thank-You Page
    • Automations
      • A/B Test
    • Security
      • Manual Review & Confirmation
      • Secondary Verification Method
      • High Risk
      • Blacklist
      • ReCaptcha
    • Reward
      • Reward Status
      • Advanced Reward Options
      • Transactions
    • Analytics
      • Active Visitors
      • Subscribers
      • Sources
      • Shares
      • Devices
      • Unsubscribers
    • Misc
      • Memorable referral links
      • 1-Click Signup
      • Forward & Refer
      • Coupon Codes
      • Custom Attribution
  • Integrate
    • Embeddable Widgets
      • Custom Domain
    • Integrations
      • Active Campaign
      • Aweber
      • Blockchain
      • Facebook Pixel
      • Calendly
      • Discord
      • HubSpot
      • Intercom
      • KakaoTalk
      • Klaviyo
      • Mailchimp
      • Salesforce
      • SendLane
      • Slack
      • Stripe
      • Tango Card
      • Telegram
      • Tremendous
      • Twilio
      • Typeform
      • Webhooks
      • Zapier
      • Zoho
    • Platform-specific Instructions
      • Google Tag Manager
      • WordPress
      • Webflow
      • SquareSpace
      • ClickFunnels
      • Unbounce
      • Instapage
      • Shopify
      • Carrd
      • WIX
    • Javascript Web API
      • Getting Started
      • Configuration file
      • Callbacks
      • Add a subscriber
      • Add a Pending Referral
      • Track multi-step conversion events
      • Track Transaction
      • Identify a Subscriber
      • Identify a Referrer
      • Generate Dashboard Widget
      • Generate Sharing-Screen
    • ReactJS
    • REST API
      • Errors
      • Webhooks
      • Objects
      • Endpoint Reference
    • Mobile SDKs
      • iOS SDK
        • Getting Started
        • Public Methods
        • Public Classes
        • API Interaction Methods
      • Android SDK
        • Getting Started
        • Public Methods
        • Public Classes
        • Listeners & Interfaces
      • Flutter SDK
        • Getting Started
        • Public Methods
      • React Native
        • Getting Started
        • Public Methods
        • Mobile App Testing in Development Mode
      • Mobile App Testing in Development Mode
  • API Tutorials
Powered by GitBook
On this page
  • 1. Add Subscriber
  • 2. Update Subscriber Details
  • 3. Get Subscriber Details
  • 4. Delete Subscriber
  • 5. Track Referral
  • 6. Capture Share
  • 7. Get My Referrals
  • 8. Get Leaderboard
  • 9. Create Pending Referral
  • 10. Organic Track Referral
  • 11. Confirm Referral
  • 12. Get Referrer
  • 13. Get Rewards

Was this helpful?

  1. Integrate
  2. Mobile SDKs
  3. iOS SDK

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"))
    }
 {
    "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,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxxx/analytics/traffic?mwr=3ab0f674",
        "created_at": 1684403108,
        "last_updated_at": 1684403108,
        "response": "subscriber_created"
    },
    "calls_left": null,
    "timestamp": 1684403108
}

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"))
{
  "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/MFxxxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxxx/analytics/traffic?mwr=dededb46",
        "created_at": 1684985427,
        "last_updated_at": 1684985427
      }
    ],
    "pagination": {
      "total_pages": 1,
      "current_page": 1,
      "per_page": 50,
      "total_objects": 1
    }

3. Get Subscriber Details

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

  RH.getSubscriberDetail()
{
    "status": "ok",
    "data": {
        "id": "sub_ee32baa54196",
        "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": "e7ceeff6",
        "position": 1,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684408479,
        "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=e7ceeff6",
        "created_at": 1684408479,
        "last_updated_at": 1684408479,
        "response": "subscriber_retrieved"
    },
    "calls_left": null,
    "timestamp": 1684414915
}

4. Delete Subscriber

This method is used to Delete a newly Created Subscriber.

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

  RH.DeleteSubscriber()
{
    "status": "ok",
    "data": {
        "id": "sub_0d7cfab3a25f",
        "name": "Test User 10",
        "email": "android3@test",
        "phone_number": "",
        "crypto_wallet_address": "",
        "crypto_wallet_provider": "",
        "extra_field": "",
        "extra_field_2": "",
        "option_field": "",
        "conversion_amount": 0,
        "code": "41eace36",
        "position": 8,
        "referred": false,
        "referred_by": {},
        "people_referred": 0,
        "promoted": false,
        "promoted_at": null,
        "verified": true,
        "verified_at": 1684831504,
        "points": 0,
        "risk_level": 0,
        "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic?mwr=41eace36",
        "created_at": 1684831504,
        "last_updated_at": 1684831504,
        "response": "subscriber_deleted"
    },
    "calls_left": null,
    "timestamp": 1685012056
}

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"))
{
  "status": "error",
  "message": "Custom Event is already completed.",
  "code": "custom_event_already_completed"
}

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")
{
  "status": "ok",
  "data": {
    "id": "sub_0d7cfab3a25f",
    "name": "Test User 10",
    "email": "android3@test",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "41eace36",
    "position": 8,
    "referred": false,
    "referred_by": {},
    "people_referred": 0,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1684831504,
    "points": 0,
    "risk_level": 0,
    "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxx/analytics/traffic",
    "source": null,
    "device": null,
    "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxx/analytics/traffic?mwr=41eace36",
    "created_at": 1684831504,
    "last_updated_at": 1684831504,
    "response": "click captured"
  },
  "calls_left": null,
  "timestamp": 1685006602
}

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()
{
  "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/MFxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/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
}

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()
{
  "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/MFxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/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/MFxxxxxxxxxx/analytics/traffic",
        "source": null,
        "device": null,
        "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
}

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"))
{
  "status": "ok",
  "data": {
    "id": "sub_1bb1e02b90cb",
    "name": "Pending Referral",
    "email": "testpending1@email.com",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "1b155f4e",
    "position": 3,
    "referred": true,
    "referred_by": {
      "id": "sub_7b9be1ed8ccb",
      "name": "Test User 10",
      "email": "test15@gmail.com",
      "code": "2c2dbefb",
      "people_referred": 0,
      "points": 0
    },
    "people_referred": 0,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1685018482,
    "points": 0,
    "risk_level": 0,
    "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic",
    "source": null,
    "device": "IOS",
    "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxx/analytics/traffic?mwr=1b155f4e",
    "created_at": 1685018482,
    "last_updated_at": 1685018482,
    "os_type": "IOS",
    "screen_size": "64*32",
    "ip_address": "123.456.789.0123",
    "response": "subscriber_created"
  },
  "calls_left": null,
  "timestamp": 1685018482
}

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"))
{
  "status": "ok",
  "data": {
    "id": "sub_41adff0cfc8e",
    "name": "Test organic User1",
    "email": "testorganic1@gmail.com",
    "phone_number": "",
    "crypto_wallet_address": "",
    "crypto_wallet_provider": "",
    "extra_field": "",
    "extra_field_2": "",
    "option_field": "",
    "conversion_amount": 0,
    "code": "23e0fb1c",
    "position": 5,
    "referred": true,
    "referred_by": {
      "id": "sub_7b9be1ed8ccb",
      "name": "Test User 10",
      "email": "test15@gmail.com",
      "code": "2c2dbefb",
      "people_referred": 0,
      "points": 0
    },
    "people_referred": 0,
    "promoted": false,
    "promoted_at": null,
    "verified": true,
    "verified_at": 1685020506,
    "points": 0,
    "risk_level": 0,
    "host": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxxx/analytics/traffic",
    "source": null,
    "device": null,
    "referral_link": "https://app.referralhero.com/dashboard/lists/MFxxxxxxxxxxx/analytics/traffic?mwr=23e0fb1c",
    "created_at": 1685020506,
    "last_updated_at": 1685020506,
    "os_type": null,
    "screen_size": null,
    "ip_address": null,
    "response": "subscriber_created"
  },
  "calls_left": null,
  "timestamp": 1685020506
}

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()
{
  "status": "error",
  "message": "Subscriber is already confirmed",
  "code": "subscriber_already_confirmed"
}

12. Get Referrer

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

RH.ReferrerList()
{
  "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,
    "code": "00598133",
    "position": 3,
    "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,
    "response": "subscriber_retrieved"
  },
  "calls_left": null,
  "timestamp": 1686554060
}

13. Get Rewards

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

RH.RewardsList()
{
  "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
      }
    ],
    "pagination": {
      "total_pages": 1,
      "current_page": 1,
      "per_page": 10,
      "total_objects": 1
    }
  },
  "calls_left": null,
  "timestamp": 1686561327
}
PreviousPublic ClassesNextAndroid SDK

Last updated 2 months ago

Was this helpful?