Cordova IOS SDK

Integration for Cordova SDK

Follow the steps below

  • Download the cordova ios plugin from download link and extract the zip file on your pc/mac and you’ll get the extracted plugin folder named as InviteReferrals_iOS.

1. Add Cordova / PhoneGap iOS Plugin

Now put plugin (i.e. InviteReferrals_iOS folder) and your your app in a same folder and add the plugin in your cordova app. To add plugin in your app open command line interface (CLI) i.e. cmd for windows and terminal for mac users and run the following commands.

cd  ~/path_to_your_cordova_app 
        cordova platform add ios
        cordova plugin add   --variable BRAND_ID=YOUR_BRAND_ID  --variable 
        ENCRYPTED_KEY=YOUR_ENCRYPTION_KEY  --variable URL_SCHEME=yourappScheme

Example:

cd  ~/Desktop/my_cordova_app 
        cordova platform add ios
        cordova plugin add ../InviteReferrals_iOS  --variable BRAND_ID=29XX8  --variable 
        ENCRYPTED_KEY=DD85448BF2678A482D5XXXX8425AAC6F --variable URL_SCHEME=inmyapp 
        //  If you add plugin correctly you will see the following in your CLI.
        ********************************************************************
        * InviteReferrals iOS Cordova plugin successfully installed *
        ********************************************************************

2. Add Referral Button

  • Use following function in your custom button click. Pass the CampaignID, Email, mobile and name inside an array at 0,1,2 and so on indexes respectively. Default campaignID will be applied if no campaignID specified.This will launch login screen of InviteReferrals.
var arg = ['Campaign_ID','Email_ID','Mobile','Name','subscriptionID' ];
InviteReferrals_iOS.launch(arg);
  • 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:

var arg = [‘12334’,’’,’’,’’,’’ ];
InviteReferrals_iOS.launch(arg);

For AutoLogin (Share Screen):

var arg = [‘12334’,’[email protected]’,’9818XXXXXX’,’Tom’,’’];
InviteReferrals_iOS.launch(arg);

3. Show Refer a friend Popup

  • Just call the following function in .js file whenever you want to show the referral program popup.
var arg = ['rule_name','email','mobile',’name’,'subscriptionID' ];
InviteReferrals_iOS.showSharePopup(arg);
  • 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:

var arg = [‘home’,’’,’’',’’,’’ ];
InviteReferrals_iOS.showSharePopup(arg);

For AutoLogin (Share Screen):

var arg = ['home','[email protected]','9818XXXXXX',’’,’’ ];
InviteReferrals_iOS.showSharePopup(arg);

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

var arg = ['email','mobile','name','gender','shareLink','shareTitle','shareDesc','shareImg','customValue','campaignID','flag','subscriptionID' ];
InviteReferrals_iOS.setupUserID(arg);

Example:

var arg = [‘[email protected]’, '9818XXXXXX', 'Tom', 'Male', 'shareLink', 'shareTitle', 'shareDesc' ,'shareImg', 'customValue', '12334', 'launch',’’ ];
InviteReferrals_iOS.setupUserID(arg);

5. Tracking Install / Register / Sale Events

  • This is how you call tracking() method to track:
var arg = ['Event_Name','Order_ID','Purchase_Vaklue','Email','Mobile','Name',isDebugMode(true/false) ];
InviteReferrals_iOS.tracking(arg);

Example:

Install

var arg = [install,'','',’','','',true ];
InviteReferrals_iOS.tracking(arg);

Register

var arg = ['register','[email protected]','999','[email protected]','9818XXXXXX','Tom',false  ];
InviteReferrals_iOS.tracking(arg);

Sale

var arg = ['sale','123AZXL43’,'999','[email protected]','9818XXXXXX','Tom',false  ];
InviteReferrals_iOS.tracking(arg);

📘

Note:

If App is on AppStore pass isDebugMode = NO in install tracking.

6. Show Welcome Message

Show welcome message to the customer if he comes through the referral of his friend.

InviteReferrals_iOS.wecomeMessage();

FAQ:

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 set Custom Font ?

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

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:
var arg = [‘Navigation_Bar_Title’, ‘Bar_Button_Title’, ‘BarTextFontName’ ‘BarTitleFontSize’, ‘BarButtonFontSize’, ‘BarButtonIconWidth’,‘BarButtonIconHeight’‘Bar_Background_Color_(RGB_or_Hex)_/_Bar_Background_Image_URl’,’Bar_Tint_Color_in_RGB_/_Hex’];
InviteReferrals_iOS.NavigationBarAttributesWithTitle(arg);

Example:

Text Titles and Rgb/Hex Colors

var arg = [‘Title’,’Close’,’Futura,22,18,0,0,’rgba(227,188,99,0.8)’,’#ffffff’];
InviteReferrals_iOS.NavigationBarAttributesWithTitle(arg);

Image Urls and Rgb/Hex Colors

var arg = [‘Title’, ’https://s3.amazonaws.com/notifyvisitors/static/cross.png’, ’’ , 22, 0, 15, 15, ’https://d2gg9evh47fn9z.cloudfront.net/thumb_COLOURBOX8392247.jpg’, ’#19bdce’];
InviteReferrals_iOS.NavigationBarAttributesWithTitle(arg);