Integration for SWIFT code
Follow the steps below
Download the sdk zip file which have some files library (.a file), header file (.h files), implementation file (.m file),Custom fonts (.ttf) and some icons (.png files), from sdk download link and include them into your project. Simply drag and include them in your project. Add “Social”,”Security” and “MessageUI” frameworks in your App. Download IOS SDK1. Configure your info.plist
Open 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 in it.Select All
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSExceptionDomains</key> <dict/> </dict> <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleURLName</key> <string>”Your Project Identifier Name”</string> <key>CFBundleURLSchemes</key> <array> <string>”yourURLscheme” </string> </array> </dict> </array> <key>LSApplicationQueriesSchemes</key> <array> </array>
You can simply open the info.plist and add the keys which works as same as above for this.
1.1. Add a new row by going to the menu and clicking Editor > Add Item. Setup a NSAppTransportSecurity as a Dictionary.
1.2. Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.
1.3. Add a new row again and set up 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 below when done.


1.4. Add a new row again and set up a LSApplicationQueriesSchemes as an Array. Fill in “whatsapp” for Item 0 as like following image.

Add a new header file and name it with 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
Select All
#import "InviteReferrals.h" #import "IR_UserResources.h"
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.h
2. Initialise the SDK
Initialize the sdk in didFinishLaunchingWithOptions function. You should be Logged into Invitereferrals account to see the correct values of BRANDID and ENCRYTEDKEY.
Select All
InviteReferrals.setupWithBrandId:(BRANDID encryptedKey:”ENCRYTEDKEY” )
Example:
Select All
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool { InviteReferrals.setupWithBrandId:(52X encryptedKey:”6F9CNXXXXXXXXXXXXXX” ) }
Add the following function in your AppDelegate file. openURL function that will check the deep linking and open your app from URL Scheme.
Select All
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool { InviteReferrals.application(application, openURL:url, sourceApplication:sourceApplication, annotation:annotation, ) return true }
3. Add Referral Button
Add the following line in your custom button click. Replace CampaignID with the id of the referral campaign. Default campaignID will be applied if no campaignID specified.This will launch login screen of InviteReferrals.
Select All
InviteReferrals.launch:(”CAMPAIGNID” email:nil mobile:nil name:nil SubscriptionID:nil)
If you want to auto login on click of above custom button pass the email id as an string to launch share screen directly.
For Login Screen:
Select All
InviteReferrals.launch:(”6823 ” email:nil mobile:nil name:nil SubscriptionID:nil)
For AutoLogin (Share Screen):
Select All
InviteReferrals.launch:(”6823 email:@”tom@gmail.com” mobile:@”9812XXXXXX” name:@”Tom” SubscriptionID:nil )
4. Show Refer a friend Popup
Just add the following line in the activity in which you want to show the referral program popup.
Select All
InviteReferrals.showSharePopup:(”Event_rule” email:nil mobile:nil name:nil SubscriptionID:nil )
If you want to auto login from show refer friend popup pass the email id as an string to launch share screen directly.
For Login Screen:
Select All
InviteReferrals.showSharePopup:(”home” email:nil mobile:nil name:nil SubscriptionID:nil)
For AutoLogin (Share Screen):
Select All
InviteReferrals.showSharePopup:(”home” ” email:@”tom@gmail.com” mobile:@”9812XXXXXX” name:@”Tom” SubscriptionID:nil )
5. Pass User Details for Auto Login (Single Sign In)
Select All
InviteReferrals.setupUserID:(”Email” mobile:nil name:nil gender:nil shareLink:nil shareTitle:nil shareDesc:nil shareImg:nil customValue:nil campignID:nil flag:nil SubscriptionID:nil )
Example:
Select All
InviteReferrals.setupUserID:(@”tom@gmail.com” mobile:@”9812XXXXXX” name:@”Tom” gender:”Male” shareLink:nil shareTitle:nil shareDesc:nil shareImg:nil customValue:nil campignID:”6823” flag:”launch” SubscriptionID:nil)
6. Tracking Install / Register / Sale Events
This is how you call tracking() method to track:
Select All
InviteReferrals.tracking:(”Even_Name” orderID:”ORDERID” purchaseValue:nil email:”email” mobile:nil name:nil isDebugMode:YES/NO)
Example:
Install
Select All
InviteReferrals.tracking:(”install” orderID:nil purchaseValue:nil email:nil mobile:nil name:nil isDebugMode:YES)
Register
Select All
InviteReferrals.tracking:(”register” orderID:”1234” purchaseValue:@”999” email:@”tom@gmail.com” mobile:@”9812XXXXXX” name:@”Tom” isDebugMode:NO)
Sale
Select All
InviteReferrals.tracking:(”sale” orderID:”2314” purchaseValue:@”999” email:@”tom@gmail.com” mobile:@”9812XXXXXX” name@”Tom” isDebugMode:NO)
Note: if App is on AppStore pass isDebugMode = NO in install tracking.
7. Show Welcome Message
Show welcome message to the customer if he comes through the referral of his friend.
Select All
InviteReferrals.welcomeMessage()
FAQ:
-
For Localise language such as Vietnamese follow the following steps.
A. Select your Project in left panel and select the Project in the next pane (NOT the Target), and under the Info tab you’ll see a section for Localizations. Click the + and choose Vietnamese (vi).
B. The next screen asks you which files you want to localize. Keep them all selected and click Finish. Note:Localizable.strings will not show up in this list, so don’t panic! At this point, Xcode has set up some directories, behind the scenes, containing separate versions of InfoPlist.strings and Main.storyboard for each language you selected.
C. Add a new file Go to File>>New>>File. Choose Strings File unders the Resource subsection. Click Next, name the file Localizable.strings, then click Save.
Note: Localizable.strings is the default filename iOS uses for localized text. Resist the urge to name the file something else, otherwise you will have to type the name of your .strings file every time you reference a localized string.
D. To let Xcode know you want it localized, select the file using the left pane, and open the File Inspector in the right pane. There you will see a button labeled Localize, click it, choose English (because it’s currently in English), and finally click Localize.
E. Now ensure that both english and Vietnamese are selected in Localization in the file inspector on right pane in xcode.
F. Go back to the left panel and click on the arrow next to Localizable.strings, so it shows the sub-elements. You now have two versions of this file: one for English and the other for Vietnamese:
G. Select Localizable.strings (English) and replace its contents with the following:
Select All
"Done" = "Done"; "OK" = "OK"; "Please enter your email." = "Please enter your email."; "Press OK to continue" = "Press OK to continue"; "Please enter a valid email." = "Please enter a valid email."; "Invalid authentication" = "Invalid authentication"; "Enter your name" = "Enter your name"; "Enter your Email" = "Enter your Email"; "Enter the Referral Program" = "Enter the Referral Program"; "How it works" = "How it works"; "Terms & Conditions" = "Terms & Conditions"; "Facebook not Logged In." = "Facebook not Logged In."; "Please login to your facebook account first." = "Please login to your facebook account first."; "Twitter not Logged In." = "Twitter not Logged In."; "Please login to your twitter account first." = "Please login to your twitter account first."; "WhatsApp not installed." = "WhatsApp not installed."; "Your device does not have WhatsApp installed." = "Your device does not have WhatsApp installed."; "Can not Send Mail" = "Can not Send Mail"; "Please login to your email account first." = "Please login to your email account first."; "More options to share" = "More options to share"; "My Referral Statistics" = "My Referral Statistics";
H. To change the text for Vietnamese,Select Localizable.strings (Vietnamese) and replace its contents with the following:
Select All
"Done" = "Làm xong"; "OK" = "được"; "Please enter your email." ="Vui lòng điền email của bạn ."; "Press OK to continue" = "Nhấn OK để tiếp tục"; "Please enter a valid email." = "Vui lòng nhập email hợp lệ."; "Invalid authentication" = "xác thực không hợp lệ"; "Enter your name" = "Nhập tên của bạn"; "Enter your Email" = "Nhập email của bạn"; "Enter the Referral Program" = "Nhập Chương trình giới thiệu"; "How it works" = "Làm thế nào nó hoạt động"; "Terms & Conditions" = "Điều khoản và điều kiện"; "Facebook not Logged In." = "Facebook không Logged In."; "Please login to your facebook account first." = "Xin hãy đăng nhập vào tài khoản facebook của bạn đầu tiên ."; "Twitter not Logged In." = "Twitter không Logged In."; "Please login to your twitter account first." = "Xin hãy đăng nhập vào tài khoản twitter của bạn đầu tiên ."; "WhatsApp not installed." = "WhatsApp không được cài đặt ."; "Your device does not have WhatsApp installed." = "WhatsApp không được cài đặt ."; "Can not Send Mail" = "Không thể Gửi Mail"; "Please login to your email account first." = "Xin hãy đăng nhập vào tài khoản email của bạn đầu tiên ."; "More options to share" = "Nhiều tùy chọn để chia sẻ"; "My Referral Statistics" = "Thống kê giới thiệu của tôi";
Make sure that the font you imported to your app is being packed into app itself. Do that by selecting your Target, then Build Phases, then Copy Bundle Resources. If you don't see your font in there, simply add them by clicking on " + " sign on left bottom of Copy Bundle Resources tab.
Select All
InviteReferrals.NavigationBarAttributesWithTitle:(”Title” BarButtonTitle:”Done Button Title / Image Url” BarTextFontName: nil BarTitleFontSize:0 BarButtonFontSize:0 BarButtonIconWidth:0 BarButtonIconHeight:0 BarBackground:"Bar Background Color (RGB or Hex) / Bar Background Image URl" BarTintColor:"Bar Tint Color in RGB / Hex")
Example:
Text Titles and Rgb/Hex Colors
Select All
InviteReferrals.NavigationBarAttributesWithTitle:(”Title” BarButtonTitle:”Closel” BarTextFontName:”Futura” BarTitleFontSize:22 BarButtonFontSize:18 BarButtonIconWidth:0 BarButtonIconHeight:0 BarBackground:"rgba(227,188,99,0.8)" BarTintColor:"#ffffff”)
Image Urls and Rgb/Hex Colors
Select All
InviteReferrals.NavigationBarAttributesWithTitle:(”Title” BarButtonTitle: ”https://s3.amazonaws.com/notifyvisitors/static/cross.png” BarTextFontName: nil BarTitleFontSize:22 BarButtonFontSize:0 BarButtonIconWidth:15 BarButtonIconHeight:15 BarBackground: "https://d2gg9evh47fn9z.cloudfront.net/thumb_COLOURBOX8392247.jpg" BarTintColor:"#19bdce")
Select All
+(void)HandleDoneButtonActionWithUserInfo:(NSMutableDictionary *)userInfo { // Do Your stuff here ………….. }