Migration From v4.5.4 To v5.0.1 And Above

Must Read:
Before moving onto migration from older version of our InviteReferrals iOS SDK(~v4.5.4 or below) to latest version of our SDK (~V5.0.1 or newer) remember that all our previous sdk public methods can be accessible in new sdk by using sharedInstance() of our class and some of our methods have been removed/merged and new method has been introduced for the same task. So read this documentation carefully which helps you to understand how to migrate from the older version of InviteReferrals iOS SDK to our latest version of SDK.

Update Previous SDK’s Public Methods Using SharedInstance:
In our previous version of InviteReferrals iOS SDK (~v4.5.4 or below) there are various public method had been available and were directly accessible using InviteReferrals class object now from our latest version of SDK (~v5.0.1 and above) these are updated and can be accessible using sharedInstance() of InviteReferrals class.

For Example:
Kindly refer to the below code example to update.

Example 1:
Initialize the SDK:
Initialize the SDK in the didFinishLaunchingWithOptions function.

Old SDK (~v4.5.4 or Below)
InviteReferrals.setup(withBrandId:  BRANDID, encryptedKey: "ENCRYPTEDKEY")

Example:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
 InviteReferrals.setup(withBrandId:  10209, encryptedKey: "C2C3B406726C2F12F4401DF0BC232B00")
return true
 }

Latest SDK (~v5.0.1 or above)
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
 }
Old SDK (~v4.5.4 or Below)
[InviteReferrals setupWithBrandId: BRANDID encryptedKey: @"ENCRYPTEDKEY"];

Example:
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[InviteReferrals setupWithBrandId: 10XXX encryptedKey: @"C2C3B406726C2F12F440XXXXXXXXXXXX"];
     return YES;
}

Latest SDK (~v5.0.1 or above)
[[InviteReferrals sharedInstance] setupWithBrandId: BRANDID encryptedKey: @"ENCRYPTEDKEY"];

Example:
-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[InviteReferrals sharedInstance] setupWithBrandId: 10XXX encryptedKey: @"C2C3B406726C2F12F440XXXXXXXXXXXX"];
     return YES;
}

Example 2:
Configure App Universal Link (DeepLink):

Add the following function in your AppDelegate file. openURL function that will check the deep linking and open your app from URL Scheme and continueUserActivity() function that will check the deep linking and open your app from App Universal Link.

Old SDK (~v4.5.4 or Below)

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
InviteReferrals.openUrl(with: app, url:  url)
return true
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
InviteReferrals.continueUserActivity(with: userActivity)
return true
}

Latest SDK (~v5.0.1 or above)

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
InviteReferrals.sharedInstance().openUrl(with: url)
return true
}


func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
InviteReferrals.sharedInstance().continueUserActivity(with: userActivity)
return true
}
Old SDK (~v4.5.4 or Below)

-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
[InviteReferrals OpenUrlWithApplication: app Url: url];
    return  nil;
}

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
 [InviteReferrals continueUserActivityWith: userActivity];
return YES;
}

Latest SDK (~v5.0.1 or above)

-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
[[InviteReferrals sharedInstance] openUrlWithUrl: url];
    return  nil;
}

-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
[[InviteReferrals sharedInstance] continueUserActivityWith: userActivity];
return YES;
}

Example 3:
Set Language:

If your App supports multiple languages then select language manually from your app. Now, you can also translate the InviteReferrals Screen Data by passing the current language Code in the following method.

Old SDK (~v4.5.4 or below)

InviteReferrals.setLocalizationLanguage("vi")
//For Vietnamese pass the language code of this language (i.e. vi)

Latest SDK (~v5.0.1 or above)

InviteReferrals.sharedInstance().setLocalizationLanguage("vi")
//For Vietnamese pass the language code of this language (i.e. vi)
Old SDK (~v4.5.4 or below)

[InviteReferrals setLocalizationLanguage:@"vi"];
//For Vietnamese pass the language code of this language (i.e. vi)

Latest SDK (~v5.0.1 or above)

[[InviteReferrals sharedInstance] setLocalizationLanguage: @"vi"];
//For Vietnamese pass the language code of this language (i.e. vi)

Important Notes:
As explained in given 3 examples you can update all the rest of the methods while migrating to our latest InviteReferrals iOS SDK (~v5.0.1 or above) for detailed information of integration steps kindly refer to our latest SDK documentation.

Update to Latest SDK’s By Replacing Previous Removed/Merged Methods:
There are some methods which have been either changed/merged in one method to perform as done in the previous version of our SDK. So you can refer to our latest SDK doc for your reference and some examples given as below.

Campaign Details, User Details & Event Info in Parameters:
Till our previous SDK (~v4.5.4 or below) there are separate fields for each and every info regarding Campaign/user/event (like campaignID, name, email, mobile, eventName, orderID, purchase value e.t.c.) and now from our latest SDK (~v5.0.1 or above) these parameters are grouped into an object related to there respective meaning like campaignInfo, userInfo, eventInfo and must be passed as an object of their respective dataTypes.

For Example:
In our old SDK CampaignID has been passed as String directly in the given parameter now from our latest SDK you can pass it using IRCampaignInfo Object, user details can be passed using IRUserInfo Object and same way event tracking details can be passed using IREventInfo object.

Let’s take an example of tracking a sale event so as in previous SDK there are separate parameters to pass all event details (like eventName, orderID, purchaseValue etc.) and user details (like email, name, mobile etc.) Now in the latest SDK (~v5.0.1 or above) you can pass these data using IREventInfo and IRUserInfo respectively as in the given parameters. Sample code of this is as follows.

Old SDK (~v4.5.4 or below)

InviteReferrals.tracking("sale", orderID: "23415", purchaseValue: "1499", email: "[email protected]", mobile: "9818XXXXXX", name: "Tom", referCode: nil, uniqueCode: nil, isDebugMode: false,  complitionHandler: nil);

Latest SDK (~v5.0.1 or above)

let eventData = IREventInfo()
eventData.eventName = "sale"
eventData.orderID = "asdf1234"
eventData.purchaseValue = 199
eventData.referrerCode = nil
eventData.uniqueCode = nil

let userData = IRUserInfo()
userData.name = "Tom"
userData.email = "[email protected]"
userData.mobileNo = "9818XXXXXX"
userData.subscriptionID = nil
userData.customValueOne = nil
userData.customValueTwo = nil
InviteReferrals.sharedInstance().trackingforEventInfo(eventData, userInfo: userData)
Old SDK (~v4.5.4 or below)

[InviteReferrals tracking: @"sale" orderID: @"421789" purchaseValue:  @"1599"  email: @"[email protected]" mobile: @"9818XXXXXX" name: @"Tom" referCode: nil uniqueCode: nil isDebugMode: NO ComplitionHandler: nil];

Latest SDK (~v5.0.1 or above)

IREventInfo *eventData = [[IREventInfo alloc] init];
eventData.eventName = @"sale";
eventData.orderID = @"asdf1234";
eventData.purchaseValue = 199;
eventData.referrerCode = nil;
eventData.uniqueCode = nil;

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"Tom";
userData.email = @"[email protected]";
userData.mobileNo = @"9818XXXXXX";
userData.subscriptionID = nil
userData.customValueOne = nil;
userData.customValueTwo = nil;
[[InviteReferrals sharedInstance] trackingforEventInfo: eventData userInfo: userData];

Launch Referral Campaign Screen (Merged and Renamed Methods):
Till our previous SDK (~v4.5.4 or below) there are separate methods were available to pass user details and to launch campaign screens and now these methods are merged and now you should use single method to launch Campaign Screen by passing campaign and user info in the given parameters as discussed previously in this doc.

For Example:
In our old SDK setupUserID() method was used to pass user details to auto-login to the campaign sharing screen and then launch() method was used to launch the campaign screen (either login / share screen) and now from our latest SDK you can use our all new campaign() method to launch our SDK Campaign screen (either login / share screen) by passing IRCampaignInfo and IRUserInfo object. Kindly refer to the below code example to update.

Old SDK (~v4.5.4 or below)

//Pass User Details:
InviteReferrals.setupUserID("EmailID", mobile: "MobileNo", name: "Name", gender: "Gender", shareLink: nil, shareTitle: nil, shareDesc: nil, shareImg: nil, customValue: nil, campaignID: "CampaignID", flag: nil, subscriptionID: nil)
//Launch IR Campaign Screen:
InviteReferrals.launch("CampaignID", email: nil, mobile: nil, name: nil, subscriptionID: nil)

For Login Screen:

InviteReferrals.launch("68XXX", email: nil, mobile: nil, name: nil, subscriptionID: nil)

For Auto Login (Share Screen):

//Pass User Details:
InviteReferrals.setupUserID("[email protected]", mobile: "9818XXXXXX", name: "Tom", gender: "male", shareLink: nil, shareTitle: nil, shareDesc: nil, shareImg: nil, customValue: nil, campaignID: "68XXX", flag: nil, subscriptionID: nil)

//Launch IR Campaign Screen:
InviteReferrals.launch("68XXX", email: nil, mobile: nil, name: nil, subscriptionID: nil)

For Auto Login (Share Screen) Using Launch Method Directly:

InviteReferrals.launch("68XXX", email: "[email protected]", mobile: "9818XXXXXX", name: "Tom", subscriptionID: nil)
//In this way IR SDK will trigger  setupUserID() method internally by using given user data and autologin will be performed directly.


Latest SDK (~v5.0.1 or above)

let campaignData = IRCampaignInfo()
campaignData.campaignID = 21XXX
campaignData.templateID = 0 
// Zero(0) refers to default UI template. Invalid templateID will also replace with default UI template. Currently 0 and 1 are valid templateID

let userData = IRUserInfo()
userData.name = "customer Name"
userData.email = "customer email"
userData.mobileNo = "User mobile no"
userData.subscriptionID = "User subscriptionID"
userData.customValueOne = "1st custom Value"
userData.customValueTwo = "2nd custom Value"
InviteReferrals.sharedInstance().campaign(campaignData, userInfo: userData) { (campaignCallback:[AnyHashable : Any]?) in
print("campaign callback response = \(String(describing: campaignCallback))")
}

For Login Screen:

let campaignData = IRCampaignInfo()
campaignData.campaignID = 21XXX
campaignData.templateID = 0
InviteReferrals.sharedInstance().campaign(campaignData, userInfo: nil) { (campaignCallback:[AnyHashable : Any]?) in
print("campaign callback response = \(String(describing: campaignCallback))")
}

For Auto Login (Share Screen):

let campaignData = IRCampaignInfo()
campaignData.campaignID = 21XXX
campaignData.templateID = 0 
let userData = IRUserInfo()
userData.name = "Tom"
userData.email = "[email protected]"
userData.mobileNo = "9818XXXXXX"
userData.subscriptionID = nil
userData.customValueOne = "1st custom Value"
userData.customValueTwo = nil
 InviteReferrals.sharedInstance().campaign(campaignData, userInfo: userData) { (campaignCallback:[AnyHashable : Any]?) in
print("campaign callback response = \(String(describing: campaignCallback))")
}


For Auto Login (Share Screen) Using Default CampaignID :

let campaignData = IRCampaignInfo()
campaignData.campaignID = 0
campaignData.templateID = 0 
let userData = IRUserInfo()
userData.name = "Tom"
userData.email = "[email protected]"
userData.mobileNo = "9818XXXXXX"
userData.subscriptionID = nil
userData.customValueOne = "1st custom Value"
userData.customValueTwo = nil
 InviteReferrals.sharedInstance().campaign(campaignData, userInfo: userData) { (campaignCallback:[AnyHashable : Any]?) in
print("campaign callback response = \(String(describing: campaignCallback))")
}
Old SDK (~v4.5.4 or below)

//Pass User Details:
[InviteReferrals setupUserID: @"EmailID" mobile: @"MobileNo" name: @"Name" gender: @"Gender" shareLink: nil shareTitle: nil shareDesc: nil shareImg: nil customValue: nil campaignID: @"CampaignID" flag: nil SubscriptionID: nil];

//Launch IR Campaign Screen:
[InviteReferrals launch: @"CampaignID" email: nil mobile: nil name: nil subscriptionID: nil];

For Login Screen:

[InviteReferrals launch: @"CampaignID" email: nil mobile: nil name: nil subscriptionID: nil];

For Auto Login (Share Screen):

//Pass User Details:
[InviteReferrals setupUserID: @"[email protected]" mobile: @"9818XXXXXX" name: @"Tom" gender: @"male" shareLink: nil shareTitle: nil shareDesc: nil shareImg: nil customValue: nil campaignID: @"68XXX" flag: nil SubscriptionID: nil];

//Launch IR Campaign Screen:
[InviteReferrals launch: @"68XXX" email: nil mobile: nil name: nil subscriptionID: nil];

For Auto Login (Share Screen) Using Launch Method Directly:

[InviteReferrals launch: @"68XXX" email: @"[email protected]" mobile: @"9818XXXXXX" name: @"Tom" subscriptionID: nil];
//In this way IR SDK will trigger  setupUserID() method internally by using given user data and autologin will be performed directly.


Latest SDK (~v5.0.1 or above)

IRCampaignInfo *campaignData = [[IRCampaignInfo alloc] init];
campaignData.campaignID = 21XXX;
campaignData.templateID = 0;
// Zero(0) refers to default UI template. Invalid templateID will also replace with default UI template. Currently 0 and 1 are valid templateID

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"customer Name";
userData.email = @"customer email";
userData.mobileNo = @"customer mobile no";
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = @"2nd custom Value";

[[InviteReferrals sharedInstance] campaign: campaignData userInfo: userData campaignCompletion:^(NSDictionary *campaignCallback) {
NSLog(@"campaign callback response = %@", campaignCallback);
}];


For Login Screen:

IRCampaignInfo *campaignData = [[IRCampaignInfo alloc] init];
campaignData.campaignID = 21XXX;
campaignData.templateID = 0;

[[InviteReferrals sharedInstance] campaign: campaignData userInfo: nil campaignCompletion:^(NSDictionary *campaignCallback) {
NSLog(@"campaign callback response = %@", campaignCallback);
}];


For Auto Login (Share Screen):

IRCampaignInfo *campaignData = [[IRCampaignInfo alloc] init];
campaignData.campaignID = 21XXX;
campaignData.templateID = 0;

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"Tom";
userData.email = @"[email protected]";
userData.mobileNo = @"9818XXXXXX";
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = nil;

[[InviteReferrals sharedInstance] campaign: campaignData userInfo: userData campaignCompletion:^(NSDictionary *campaignCallback) {
NSLog(@"campaign callback response = %@", campaignCallback);
}];

For Auto Login (Share Screen) Using Default CampaignID :

IRCampaignInfo *campaignData = [[IRCampaignInfo alloc] init];
campaignData.campaignID = 0;
campaignData.templateID = 0;

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"Tom";
userData.email = @"[email protected]";
userData.mobileNo = @"9818XXXXXX";
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = nil;

[[InviteReferrals sharedInstance] campaign: campaignData userInfo: userData campaignCompletion:^(NSDictionary *campaignCallback) {
NSLog(@"campaign callback response = %@", campaignCallback);
}];

Show Refer a friend Popup (Renamed to Campaign Popup):
if you want to notify your user to enroll into your referral program by using s Modal popup, Till our previous SDK (~v4.5.4 or below) you were able to use showSharePopup() method and now from our latest SDK (~v5.0.1 or above) this method renamed and updated with new method named as campaignPopup().

So you can now notify your user to enroll into your referral program by following code example. To use this feature you need to define a campaignPopup Rule name first in your InviteReferrals dashboard to do so goto campaign setting under Integration>>Mobile App setting and configure a rule here and use the same rule name in your cose as shown below (For Example suppose if a rulename lets say “referralInvite” is configured in the campaign settings)

Old SDK (~v4.5.4 or Below)

InviteReferrals.showSharePopup("referralInvite", email: "[email protected]", mobile: "9818XXXXXX", name: "Tom", subscriptionID: nil);

Latest SDK (~v5.0.1 or above)

let campaignData = IRCampaignInfo()
campaignData.campaignID = 21XXX
campaignData.templateID = 0 
// Zero(0) refers to default UI template. Invalid templateID will also replace with default UI template. Currently 0 and 1 are valid templateID

let userData = IRUserInfo()
userData.name = "customer Name"
userData.email = "customer email"
userData.mobileNo = "customer mobile no"
userData.subscriptionID = "customer subscriptionID"
userData.customValueOne = "1st custom Value"
userData.customValueTwo = "2nd custom Value"
InviteReferrals.sharedInstance().campaignPopup(forRuleName: "referralInvite", campaignInfo: campaignData, userInfo: userData)
Old SDK (~v4.5.4 or Below)

[InviteReferrals showSharePopup: @"referralInvite" email: @"[email protected]" mobile: @"9818XXXXXX" name: @"Tom" subscriptionID: nil];

Latest SDK (~v5.0.1 or above)

IRCampaignInfo *campaignData = [[IRCampaignInfo alloc] init];
campaignData.campaignID = 21XXX;
campaignData.templateID = 0;
// Zero(0) refers to default UI template. Invalid templateID will also replace with default UI template. Currently 0 and 1 are valid templateID

IRUserInfo *userData = [[IRUserInfo alloc] init];
userData.name = @"customer Name";
userData.email = @"customer email";
userData.mobileNo = @"customer mobile no";
userData.customValueOne = @"1st custom Value";
userData.customValueTwo = @"2nd custom Value";

[[InviteReferrals sharedInstance] campaignPopupForRuleName: @"ruleName" campaignInfo: campaignData userInfo: userData];

Important Notes:
As above explained in given examples you can update all the rest of the methods while migrating to our latest InviteReferrals iOS SDK (~v5.0.1 or above) for detailed information of integration steps kindly refer to our latest SDK documentation.