Integration

Now comes the integration step; here, we have discussed the mandatory steps you need to complete in order to integrate the InviteReferrals SDK with your IOS application. To add the latest version to your project, follow the steps below.

Have a look at them one by one: -

1. Configure Your Info.plist

To configure your info.plist. Navigate to the info.plist of your project as source code (right click on info.plist and click on Open as >> Source code) and add the following code.

<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>

Or you can simply open the info.plist and add the keys which work the same as above.

1.1 Add a new row by going to the menu and clicking Editor > Add Item. Setup a URL Types item by adding a new item. Expand the URL Types key, expand Item 0, and add a new item, URL schemes. Fill in “appScheme” for Item 0 of URL schemes and your company identifier for the URL Identifier. Your file should resemble the image given below.

938

1.2 Add a new row again and set up a LSApplicationQueriesSchemes as an Array. Fill in “whatsapp” for Item 0 , “fb” for item 1 and “twitter” for item 2 as the following image.

823

2. Import InviteReferrals SDK Into Your Project

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

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.

2.1. Open terminal and install cocoapods in your Mac if not installed yet. Type the following command in your terminal app to install the cocoapods in your system.

$ sudo gem install cocoapods

2.2. Now if you don’t have a Podfile then create it first. To do so inside the terminal app go to your Xcode project root folder using 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

And now inside the root folder of your project in the terminal run the following command to generate a Podfile into your project’s root folder.

$ pod init

2.3. Now Open your Podfile or the newly created podfile with your favorite text Editor like: textEdit, Vim, Sublime etc.

2.4. Add the InviteReferrals dependency under your project name target like below.

target 'Your_ProjectName' do
     pod 'InviteReferrals'
end

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

$ pod repo update
$ pod install

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

📘

NOTE

Make sure to always open the workspace from now on.

Option 2: Manual Integration

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

3. Import Header File

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.

📘

NOTE

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

#import <InviteReferrals/InviteReferrals.h>
#import "InviteReferrals.h"

4. Initialize The SDK

Initialize the SDK in the didFinishLaunchingWithOptions function.

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

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


InviteReferrals.sharedInstance().setup(withBrandId: 10XXX, encryptedKey: "C2C3B406726C2F12F440XXXXXXXXXXXX”)
return true
 }
[[InviteReferrals sharedInstance] setupWithBrandId: BRANDID encryptedKey: @"ENCRYPTEDKEY"];

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

📘

NOTE

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