Integration

The new SDK for IOS helps you to run a referral campaign in InviteReferrals. Read this guide to know the basic integration of the referral campaign, how to track the events, how to show a welcome message, and other important information via FAQs.

A comprehensive guide to integrate your IOS app with InviteReferrals IOS SDK.

Below are the integration steps :

CONFIGURE YOUR INFO.PLIST

Navigate to the info.plist of your project as a source code. Simply, right-click on the info.plist and click on Open as >> Source code. Then, add the below code in it :

<key>CFBundleURLTypes</key>
  <array>
        <dict>
      <key>CFBundleURLName</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
                <key>CFBundleURLSchemes</key>
                <array>
    <string>”yourURLscheme comes here”</string>
         </array>
        </dict>
          </array>
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>whatsapp</string>
        <string>fb</string>
        <string>twitter</string>
    </array>

📘

Note : You can follow another option to configure the info.plist by simply opening the info.plist & adding the keys which works the same as above for this.

a. Add a new row by navigating to the menu and clicking on the Editor> Add item. Set up URL types item by adding a new item. Expand the URL types and item 0 and add a new item, i.e. URL schemes. Next, put in “appScheme” for Item 0 of URL schemes and fill in your company identifier for the URL identifier.

Your file must resemble the image that is given below :

512512

b. Add up a new row again and set up an LSApplicationQueriesSchemes as an Array. Put the value “WhatsApp” for Item 0, “FB” for item 1, and “Twitter” for item 2 as given in the below image :

884884

IMPORT INVITEREFERRALS SDK TO YOUR PROJECT

Add “Social”, ”Security” and “MessageUI” frameworks in your App.

There are two options through which you can import InviteReferrals SDK to your project.

Option 1: Integration through CocoaPods

You can make integration easier using Cocoapods in your Objective C or Swift project as Cocoapods is the dependency manager for Objective-C and Swift projects.

a. Open a terminal and install cocoapods in your Mac. Type the following command in your terminal app in
order to install the cocoapods in your system.

$ sudo gem install cocoapods

b. Now, create the Podfile if you do not have one. In order to create one, go to the Xcode project root folder inside the terminal app, using the CD command.

For Example: if your Project is saved on Desktop and its root folder name is MyAPP, then go to your project root folder by using the following command.

$ cd ~/Desktop/MyApp

Next, run the below command to generate a pod file into your project’s root folder.

$ pod init

c. Next, open your Podfile, the file you created above with the text editor like TextEdit, Vim, Sublime, etc.

d. Add the InviteReferrals dependency under your project name as given below :

target 'Your_ProjectName' do
     pod 'InviteReferrals'
end

e. Make sure your current Xcode project is closed. Now, run the following command from the terminal in the project root.

$ pod repo update
$ pod install

f. Now open the newly created <Your_Project_Name>.xcworkspace file.

📘

Note: Remember to always open the workspace from now on.

OR

Option 2: Manual Integration

Download the SDK .zip file which has the following files: library (.a file), a header file (.h file), user resource file (.plist file), some images (.png file), and a .plist file from the SDK download link and include them into your project. Simply drag and include them in your project.

IMPORT HEADER FILE

You can either chose the option one or option two to import InviteReferrals SDK.

Objective C

Import the InviteReferrals header file in each file in which the SDK function is to be accessed as given below.

Swift

Add a new header file and name it with the following format.

YOUR_PROJECT_NAME-Bridging-Header.h

Example

IF your project name is test, then the header file name will be test-Bridging-Header.h. Now, add the following import statement in YOUR_PROJECT_NAME-Bridging-Header.h for accessing Native SDK Classes.

📘

Make sure that the path of bridge-header.h file is included in build settings under "Swift compiler-code generation" as Objective C bridging header: YOUR_PROJECT_NAME/YOUR_PROJECT_NAME-Bridging-Header.h

If you are using Option one, i.e, Integration Through Cocoapads, pass the following code

​​#import <InviteReferrals/InviteReferrals.h>

If you are using option two, i.e. Manual Integration, pass the following code

#import "InviteReferrals.h"

INITIALIZE THE SDK :

Initialize the SDK in the didFinishLaunchingWithOptions function.

InviteReferrals.setup(withBrandId:  BRANDID, encryptedKey: "ENCRYPTEDKEY")

Example:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

 InviteReferrals.setup(withBrandId:  10209, encryptedKey: "C2C3B406726C2F12F4401DF0BC232B00")
return true
 }
[InviteReferrals setupWithBrandId: BRANDID encryptedKey: @"ENCRYPTEDKEY"];

Example:
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[InviteReferrals setupWithBrandId: 10XXX encryptedKey: @"C2C3B406726C2F12F440XXXXXXXXXXXX"];
     return YES;
}

📘

Note: You can login to your IR_account to see your credentials for the brand ID and Encryption Keys. The credentials in the above image are dummy.

CONFIGURE THE APP UNIVERSAL LINK :

Add the following function in your AppDelegate file. openURL function to check the deep linking and open your app from the URL Scheme. Next, continueUserActivity() function to check the deep linking and open your app from App Universal Link.

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
     InviteReferrals.openUrl(with:  app, url:  url)
     return true
}



func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {

InviteReferrals.continueUserActivity(with: userActivity)
return true
}
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
[InviteReferrals OpenUrlWithApplication: app Url: url];
return  nil;
}

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  [InviteReferrals continueUserActivityWith: userActivity];
return YES;
}

a.To configure InviteReferrals App Universal Link : Go to your InviteReferral Dashboard and follow the App Universal link Setup Guide from documentation Under Setup Guide Section (i.e. InviteReferral App Universal Link Setup Guide).

b. Go to the Signing & Capabilities Tab If “Associated Domains” is not already added. Next, click on the + symbol on the left corner of this tab and add Associated Domains. Now click + sign under “Associated Domains” to add a new associated domain and here copy & paste the value for Your Associated Domain value given in the InviteReferral App Universal Link Setup Guide

512512

Paste the above value in your App as given in the below Image.

512512

SET LANGUAGE:

You can choose to translate the InviteReferrals Screen Data bypassing the current language code in the following method, in case your app supports multiple languages. Simply select the language manually from your app.

InviteReferrals.setLocalizationLanguage("vi")
 // For Vietnamese pass the language code of this language (i.e. vi)
[InviteReferrals setLocalizationLanguage: @"vi"];  
// For Vietnamese pass the language code of this language (i.e. vi)