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
  • Getting Started
  • Manually
  • Tracking Referrals

Was this helpful?

  1. Integrate
  2. Mobile SDKs
  3. iOS SDK

Getting Started

ReferralHero iOS Swift SDK

PreviousiOS SDKNextPublic Methods

Last updated 2 months ago

Was this helpful?

Getting Started

To start using the ReferralHero SDK, you will need to add it to your project as a framework. These can be downloaded from Here:

Manually

Step 1.

1. Visit the ReferralHero iOS SDK repository on GitHub: (https://github.com/maitre-app/ReferralHero-iOS).

2. You can either clone the repository using Git or download the ZIP file directly from GitHub. To clone, use the terminal with the command: `git clone https://github.com/maitre-app/ReferralHero-iOS.git`. If downloading the ZIP, extract it to a known location on your system.

Step 2.

1. Open your Xcode project.

2. Right-click on your project navigator and select "Add Files to [YourProjectName]".

3. Navigate to the location where you cloned or extracted the ReferralHero SDK. You should add the entire `ReferralHero.framework` to your project. Make sure "Copy items if needed" is checked so the framework is copied into your project directory.

Step 2.

1. Select your project in the Project Navigator to bring up the project settings.

2. Select your target and go to the "General" tab.

3. Scroll down to "Frameworks, Libraries, and Embedded Content".

4. Make sure `ReferralHero.framework` is listed and set to "Embed & Sign". This ensures the framework will be embedded into your app's bundle.

Step 3.

Import ReferralHero in AppDelegate.swift

import UIKit
import ReferralHero_iOS

If there is no AppDelegate, where @main identifier is present in App function

import SwiftUI
import ReferralHero_iOS

@main
struct Rh_TesteApp: App {

Step 4.

Import ReferralHero in AppDelegate.swift., Or where @main identifier is present in App function.

  • Back in the ReferralHero overview, click to edit your desired Campaign

  • Then the Installation tab, then Mobile App Installation

  • Get your UUID: The 12-letter ID that starts with ‘MF’ in Edit Campaign > launch > Mobile app installation, e.g. MFxxxxxxxxx

Now, you should add The Campaign Token Obtained from the campaign, and UUID from the installation Tab.


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
   
        RHApiKey.configure(withAPIKey: "API_TOKEN", withuuID: "UUID")
        return true
    }

Step 5.

In the Goal section of your Campaign settings, ensure you have added the Google Play and Apple App Store links and a default referral link for desktop web users.

Well done! You should now be able to build and run your campaign. Before using the more advanced features of the SDK, you should learn about a couple of important concepts.

There are a few major components in the SDK that you can include in your app.

Tracking Referrals

Now that you have implemented the SDK, you can start identifying and tracking referrals!

For that, you will need 2 things:

  1. Universal Link

  2. Your Integrated App

The RH SDK Pulls information from your Device, like this:

networkManager.getPublicIPAddress { IP in
    if let ipAddress = IP {
        RHApiKey.IP = ipAddress
        print("getPublicIPAddress.\(ipAddress)")
        } else {
            print("Unable to fetch the public IP address.")
        }
}
RHApiKey.Device = networkManager.getDeviceInfo().modelName
RHApiKey.OS = networkManager.getDeviceInfo().osVersion
RHApiKey.SCREEN_SIZE = networkManager.getScreenSize()

With this information, you should be able to add the subscriber data, with the Get Referrer, Add Subscriber, Create Pending Referral, or Track Referral methods to automatically identify or track a referral:

var param = RHSubscriber(
    email: "xyz@gmail.com", //Required value, capture this from user
    domain: "www.abc.com", //Required value, should match the default referral link set within your RH account
    name: “ABC", //Optional but recommended, capture this from user
    referrer: "53f8acf7", //Optional value, only necessary if the user will provide the referrer code directly, otherwise the below 4 params are required
    IPAddress: "201.202.203.205", //Required value, necessary if you want RH to automatically identify & create a referral without the user providing the setReferrer params, see below
    device: "iPhone", //Required value, see below
    screen_size: "370.0 x 480.0", //Required value, see below
    os_type:"iOS", //Required value, see below
    status: "custom_event_pending" //Use 'custom_event_pending' to set the referral status to pending
)

public func formSubmit(param: RHSubscriber){
    WEB_SER.api_POST(endPoint: subscribers, param: param.toDictionary())
    { [self] (result,data) in
        switch result{
            case .success(let response):
            // ...
            case .failure(let err):
            // ...
        }
    }
}

To further understand the implementation of these methods, please check the Public Methods section, and our Github Sample Project.

Get your API_TOKEN from the ReferralHero Dashboard -> API :

https://app.referralhero.com/dashboard/apis
https://github.com/maitre-app/ReferralHero-iOS