Xamarin IOS SDK

Integration for Xamarin IOS

Follow the steps below

  • Download the xamarin ios library from download link and add the library project to your project Solution.
  • Double click on Reference and goto PROJECTS tab and select Invitereferrals and click on OK button.Now Invitereferrals should be shown in Reference folder as following image
294

1. Configure your info.plist

Goto info.plist click on Source tab.

1.1. Click on Add new entry and set up a NSAppTransportSecurity as a Dictionary. Add a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

1.2. Go To Application Tab and check Bundle Identifier inside iOS Application Target section. This Bundle Identifier will be used in next step.

1.3. Add a new entry 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.

754

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

869
  • Include namespace in each .cs file in which sdk function is to be accessed.
using Invitereferrals;

2. Initialise the SDK

  • Initialize the sdk in OnActivated function. You should be Logged into Invitereferrals account to see the correct values of BRANDID and ENCRYTEDKEY.
InviteReferrals.SetupWithBrandId (BRANDID ,"ENCRYTEDKEY" );

Example:

public override void OnActivated (UIApplication application)  { 
InviteReferrals.SetupWithBrandId (29XX8 ,"DD85448BF2XXXX482D5F8C28425AAC6F" );
}

Add the following function in your AppDelegate.cs file. openURL function that will check the deep linking and open your app from URL Scheme.

public override bool OpenUrl (UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)  {
InviteReferrals.Application (application, url, sourceApplication, annotation);
throw new System.NotImplementedException ();
}

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.

InviteReferrals.Launch(“campaignID”,“email” ,”mobile” ,”name” ,”subscriptionID” );
  • 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:

InviteReferrals.Launch(“6823”,””,””,””,”” );

For AutoLogin (Share Screen):

InviteReferrals.Launch(“6823”,”[email protected]”,”9818XXXXXX”,”Tom”,”” );

4. Show Refer a friend Popup

  • Just add the following line in the ViewController in which you want to show the referral program popup.
InviteReferrals.ShowSharePopup (“page”,”email”,”mobile”,”name”,”subscriptionID” );
  • 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:

InviteReferrals.ShowSharePopup (“home”,””,””,””,”” );

For AutoLogin (Share Screen):

InviteReferrals.ShowSharePopup (“home”,”[email protected]”,”9818XXXXXX”,”Tom”,”” );

5. Pass User Details for Auto Login (Single Sign In)

InviteReferrals.SetupUserId(“email”,”mobile”,”name”,”gender”,”shareLink”,”shareTitle”,”shareDesc”,”shareImg”,”customValue”, ”campaignid”,”flag”,”subscriptionID” );

Example:

InviteReferrals.SetupUserId(“[email protected]”,”9918XXXXXX”,”Tom”,”male”,”shareLink”,”shareTitle”,”shareDesc”,”shareImg”,”customValue”,”6823”,”launch”,”” );

6. Tracking Install / Register / Sale Events

  • This is how you call tracking() method to track:
InviteReferrals.Tracking(“eventName”,”orderID”,”purchaseValue”,”email”,”mobile”,”name”,”isDebugMode” );

Example:

Install

InviteReferrals.Tracking(“install”,””,””,””,””,””, true );

Register

InviteReferrals.Tracking(“register”,”[email protected]”,”2000”,”[email protected]”,”9818XXXXXX”,”Tom”,false );

Sale

InviteReferrals.Tracking(“sale”,”123466”,”2000”,”[email protected]”,”9818XXXXXX”,”Tom”,false );

📘

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.
InviteReferrals.welcomeMessage();

FAQs:

Q1. How to set Background image ?

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

Q2. How to translate InviteReferrals screen into localise language as per default language of iOS device?

  • For Localise language such as Vietnamese follow the following steps.

A. Select your Info.plist of your Xamarin iOS project solution.Click on Add new entry and Setup a CFBundleDevelopmentRegion as a String set its value to en where en stands for English. This step will set the default supported language English if no translation supported language found default value will be used.

B. Add new entry and set up a CFBundleLocalizations as a Array. Add languages you want to supported by your app as the elements of above array for example if your app supports two languages English (en) and Vietnamese (vi) as the elements of the CFBundleLocalizations Array same as the following image.

C. Create a Resources folder in your iOS project solution and inside the Resources folder create a folder with the .lproj extension for each language and create a Localizable.strings file in each of the .lproj folder.For above example there should be two folders en.lproj and vi.lproj. Also make sure all .strings files should apply for BundleResource build action.To check that right click on .strings file >> Build Action >> BundleResource.

D. Now as per above example open the Localizable.strings file of en.lproj and replace its contents with the following.

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

E. Now open the Localizable.strings file of vi.lproj and replace its contents with the following.

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

Q3. I want to Customise Navigation Bar used in InviteReferrals screens.How can I do That ?

  • You can also customise navigation bar as your choice for Invitereferrals screens to do that just call the following:
InviteReferrals.NavigationBarAttributesWithTitle ("Title", "Done Button Title / Image Url", "BarTextFontName", BarTitleFontSize, BarButtonFontSize, BarButtonIconWidth, BarButtonIconHeight, "Bar Background Color (RGB or Hex) / Bar Background Image URl", "Bar Tint Color in RGB / Hex");

Example:

Text Titles and Rgb/Hex Colors

InviteReferrals.NavigationBarAttributesWithTitle ("Title", "Close", "Futura", 22, 18, 0, 0, "rgba(227,188,99,0.8)", "#ffffff");

Image Urls and Rgb/Hex Colors

InviteReferrals.NavigationBarAttributesWithTitle("Title","https://s3.amazonaws.com/notifyvisitors/static/cross.png","",22,0,15,15,"https://d2gg9evh47fn9z.cloudfront.net/thumb_COLOURBOX8392247.jpg","#19bdce");