Integration for Objective C 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 SDK

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

OR

You can simply open the info.plist and add the keys which works as same as above for this.



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

    -(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
    [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

    
    -(BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
    [InviteReferrals application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
    return YES;                                   
    }

    


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.

Select All

For Login Screen:

    [InviteReferrals launch:@”6823”  email:nil mobile:nil name:nil SubscriptionID:nil ];
    

Select All

For AutoLogin (Share Screen):

    [InviteReferrals launch:@”6823”  email:@”tom@gmail.com”  mobile:9818XXXXXX name:Tom SubscriptionID:nil];
    

4. Show Refer a friend Popup

Just add the following line in the ViewController 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.

Select All

For Login Screen:

    [InviteReferrals showSharePopup: @”home”  email:nil   mobile:nil   name:nil   SubscriptionID:nil  ];
    

Select All

For AutoLogin (Share Screen):

    [InviteReferrals showSharePopup: @”home”email:@”email@domain.com”   mobile:nil name:nil 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:


You can also set background image of your choice for Invitereferrals screens to do that just rename your background image as “bg.png” and import it to your project’s Assets or simply drag and include it in your project.
        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";
      
              

You can use Custom fonts for InviteReferrals Screens texts to match with your App’s text fonts. To do this Add fonts .ttf files inside Font folder to your XCode project. Edit info.plist file. Add Fonts provided by application key into your plist and in Item 0 copy the exact filename of the font you copied to your XCode project WITH extension. For example: "DroidSans-Bold.ttf".

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.
You can also customise navigation bar as your choice for Invitereferrals screens to do that just call the following m

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:

Select All

Text Titles and Rgb/Hex Colors

        [InviteReferrals NavigationBarAttributesWithTitle: @”Title” BarButtonTitle: @”Closel” BarTextFontName: @”Futura” BarTitleFontSize:22 BarButtonFontSize:18 BarButtonIconWidth:0 BarButtonIconHeight:0 BarBackground:@"rgba(227,188,99,0.8)" BarTintColor:@"#ffffff”];
        

Select All

Image Urls and Rgb/Hex Colors

        [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"];
        

As you have already imported IR_UserResources .h and .m file goto IR_UserResources.m file and add your code inside HandleDoneButtonActionWithUserInfo as follows:

Select All


        +(void)HandleDoneButtonActionWithUserInfo:(NSMutableDictionary *)userInfo {
        // Do Your stuff here …………..   
        }