diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index 5c5cc952..9747ede7 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -1,15 +1,29 @@ // // BranchSDK.h -// Branch-TestBed +// Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK // -// Created by Lysis on 1/14/16. // Copyright © 2016 Branch Metrics. All rights reserved. // +#import +#import +#import #import @interface BranchSDK : CDVPlugin +@property (copy) NSString *canonicalIdentifier; +@property (copy) NSString *title; +@property (copy) NSString *contentDescription; +@property (copy) NSString *imageUrl; +@property (copy) NSString *type; +@property (copy) NSArray *keywords; +@property (copy) NSDictionary *metadata; +@property (copy) NSDate *expirationDate; + +@property (strong, nonatomic) BranchUniversalObject *branchUniversalObj; + +// BranchSDK Basic Methods - (void)initSession:(CDVInvokedUrlCommand*)command; - (void)setDebug:(CDVInvokedUrlCommand*)command; - (void)getAutoInstance:(CDVInvokedUrlCommand*)command; @@ -20,4 +34,19 @@ - (void)userCompletedAction:(CDVInvokedUrlCommand*)command; - (void)logout:(CDVInvokedUrlCommand*)command; +// Branch Referral Reward System +- (void)loadRewards:(CDVInvokedUrlCommand*)command; +- (void)redeemRewards:(CDVInvokedUrlCommand*)command; +- (void)getCreditHistory:(CDVInvokedUrlCommand*)command; + +// Branch Universal Object Methods +- (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command; +- (void)initWithCanonicalIdentifier:(CDVInvokedUrlCommand*)command; +- (void)initWithTitle:(CDVInvokedUrlCommand*)command; +- (void)addMetadata:(CDVInvokedUrlCommand*)command; +- (void)registerView:(CDVInvokedUrlCommand*)command; +- (void)generateShortUrl:(CDVInvokedUrlCommand*)command; +- (void)showShareSheet:(CDVInvokedUrlCommand*)command; +- (void)listOnSpotlight:(CDVInvokedUrlCommand*)command; + @end diff --git a/src/ios/BranchSDK.m b/src/ios/BranchSDK.m index e71efd3f..b6c5134b 100644 --- a/src/ios/BranchSDK.m +++ b/src/ios/BranchSDK.m @@ -1,14 +1,11 @@ // // BranchSDK.m -// Branch-TestBed +// Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK // -// Created by Lysis on 1/14/16. // Copyright © 2016 Branch Metrics. All rights reserved. // #import "BranchSDK.h" -#import -#import @implementation BranchSDK @@ -38,8 +35,36 @@ - (Branch *)getTestInstance return [Branch getTestInstance]; } -#pragma mark Public APIs -#pragma mark - InitSession Permutation methods +#pragma mark - Deep Linking Handlers + +- (id)handleDeepLink:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start handleDeepLink"); + NSString *arg = [command.arguments objectAtIndex:0]; + NSURL *url = [NSURL URLWithString:arg]; + + Branch *branch = [self getInstance]; + return [NSNumber numberWithBool:[branch handleDeepLink:url]]; +} + +- (void)continueUserActivity:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start continueUserActivity"); + + NSString *activityType = (NSString *)[command.arguments objectAtIndex:0]; + NSDictionary *userInfo = (NSDictionary*)[command.arguments objectAtIndex:1]; + + NSUserActivity *userActivity = [[NSUserActivity alloc] initWithActivityType:activityType]; + [userActivity setUserInfo:userInfo]; + + Branch *branch = [self getInstance]; + + NSLog(@"continuing user activity..."); + [branch continueUserActivity:userActivity]; +} + +#pragma mark - Public APIs +#pragma mark - Branch Basic Methods - (void)initSession:(CDVInvokedUrlCommand*)command { @@ -65,7 +90,7 @@ - (void)initSession:(CDVInvokedUrlCommand*)command } } else { NSLog(@"No data found"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Empty data"]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Empty data"]; } } else { @@ -112,7 +137,7 @@ - (void)getLatestReferringParams:(CDVInvokedUrlCommand*)command } } else { NSLog(@"No data found"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Empty data"]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Empty data"]; } NSLog(@"returning data to js interface.."); [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; @@ -141,7 +166,7 @@ - (void)getFirstReferringParams:(CDVInvokedUrlCommand*)command } } else { NSLog(@"No data found"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Empty data"]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Empty data"]; } NSLog(@"returning data to js interface.."); [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; @@ -171,7 +196,7 @@ - (void)setIdentity:(CDVInvokedUrlCommand*)command } else { NSLog(@"No data found"); - pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Empty data"]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Empty data"]; } NSLog(@"returning data to js interface.."); [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; @@ -188,6 +213,7 @@ - (void)registerDeepLinkController:(CDVInvokedUrlCommand*)command - (void)userCompletedAction:(CDVInvokedUrlCommand*)command { + NSLog(@"start userCompletedAction"); NSString *name; NSDictionary *state; // if a state dictionary is passed as an argument @@ -214,6 +240,356 @@ - (void)logout:(CDVInvokedUrlCommand*)command NSLog(@"start logout"); Branch *branch = [self getInstance]; [branch logout]; + self.branchUniversalObj = nil; +} + +#pragma mark - Branch Referral Reward System + +- (void)loadRewards:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start loadRewards"); + Branch *branch = [self getInstance]; + + [branch loadRewardsWithCallback:^(BOOL changed, NSError *error) { + NSLog(@"inside loadRewardsWithCallback block"); + CDVPluginResult* pluginResult = nil; + if(!error) { + NSNumber *credits = [NSNumber numberWithInteger:[branch getCredits]]; + NSError *err; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{@"credits":credits} + options:0 + error:&err]; + if (!jsonData) { + NSLog(@"Parsing Error: %@", [err localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[err localizedDescription]]; + } else { + NSLog(@"Success"); + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString]; + } + } + else { + NSLog(@"Load Rewards Error: %@", [error localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} + +- (void)redeemRewards:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start redeemRewards"); + NSInteger amount = ((NSNumber *)[command.arguments objectAtIndex:0]).integerValue; + Branch *branch = [self getInstance]; + + [branch redeemRewards:amount callback:^(BOOL changed, NSError *error) { + NSLog(@"inside redeemRewards block"); + CDVPluginResult* pluginResult = nil; + if (!error) { + NSNumber *changedValue = [NSNumber numberWithBool:changed]; + NSError *err; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{@"changed":changedValue} + options:0 + error:&err]; + if (!jsonData) { + NSLog(@"Parsing Error: %@", [err localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[err localizedDescription]]; + } else { + NSLog(@"Success"); + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString]; + } + } + else { + NSLog(@"Redeem Rewards Error: %@", [error localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} + +- (void)getCreditHistory:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start getCreditHistory"); + Branch *branch = [self getInstance]; + + [branch getCreditHistoryWithCallback:^(NSArray *list, NSError *error) { + NSLog(@"inside getCreditHistoryWithCallback block"); + CDVPluginResult* pluginResult = nil; + if (!error) { + NSError *err; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:list + options:0 + error:&err]; + if (!jsonData) { + NSLog(@"Parsing Error: %@", [err localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[err localizedDescription]]; + } else { + NSLog(@"Success"); + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString]; + } + } + else { + NSLog(@"Credit History Error: %@", [error localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} + +#pragma mark - Branch Universal Object Methods + +- (void)createBranchUniversalObject:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start createBranchUniversalObject"); + + NSDictionary *properties = [command.arguments objectAtIndex:0]; + self.branchUniversalObj = [[BranchUniversalObject alloc] init]; + + for (id key in properties) { + if ([key isEqualToString:@"contentMetadata"]){ + NSDictionary *metadata = (NSDictionary *)[properties valueForKey:key]; + + for (id key_ in metadata) { + [self.branchUniversalObj addMetadataKey:key_ value:[metadata valueForKey:key_]]; + } + } + else if ([key isEqualToString:@"contentIndexingMode"]) { + NSString *indexingMode = [properties valueForKey:key]; + if ([indexingMode isEqualToString:@"private"]) { + self.branchUniversalObj.contentIndexMode = ContentIndexModePrivate; + + } + else if ([indexingMode isEqualToString:@"public"]){ + self.branchUniversalObj.contentIndexMode = ContentIndexModePublic; + } + } + else if ([key isEqualToString:@"contentImageUrl"]){ + NSString *imageUrl = [properties valueForKey:key]; + self.branchUniversalObj.imageUrl = imageUrl; + } + else { + [self.branchUniversalObj setValue:[properties objectForKey:key] forKey:key]; + } + } + + NSLog(@"init BUO - %@", self.branchUniversalObj); + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"createBranchUniversalObject Success"]; + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)initWithCanonicalIdentifier:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start initWithCanonicalIdentifier"); + if (!self.branchUniversalObj) { + self.branchUniversalObj = [[BranchUniversalObject alloc] initWithCanonicalIdentifier:[command.arguments objectAtIndex:0]]; + } + else { + self.branchUniversalObj.canonicalIdentifier = [command.arguments objectAtIndex:0]; + } + + NSLog(@"init BUO - %@", self.branchUniversalObj); + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"createBranchUniversalObject Success"]; + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)initWithTitle:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start initWithTitle"); + if (!self.branchUniversalObj){ + self.branchUniversalObj = [[BranchUniversalObject alloc] initWithTitle:[command.arguments objectAtIndex:0]]; + } + else { + self.branchUniversalObj.title = [command.arguments objectAtIndex:0]; + } + + NSLog(@"init BUO - %@", self.branchUniversalObj); + CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"createBranchUniversalObject Success"]; + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; +} + +- (void)addMetadata:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start addMetadata"); + NSDictionary *metadata = [command.arguments objectAtIndex:0]; + [self.branchUniversalObj addMetadataKey:[metadata objectForKey:@"key"] value:[metadata objectForKey:@"value"]]; +} + +- (void)registerView:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start registerView"); + [self.branchUniversalObj registerView]; +} + +- (void)generateShortUrl:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start generateShortUrl"); + NSDictionary *arg1 = [command.arguments objectAtIndex:0]; + NSDictionary *arg2 = [command.arguments objectAtIndex:1]; + + BranchLinkProperties *props = [[BranchLinkProperties alloc] init]; + + for (id key in arg1) { + if ([key isEqualToString:@"duration"]) { + props.matchDuration = (NSUInteger)[((NSNumber *)[arg1 objectForKey:key]) integerValue]; + } + else { + [props setValue:[arg1 objectForKey:key] forKey:key]; + } + } + + for (id key in arg2) { + [props addControlParam:key withValue:[arg1 objectForKey:key]]; + } + + [self.branchUniversalObj getShortUrlWithLinkProperties:props andCallback:^(NSString *url, NSError *error) { + NSLog(@"inside getShortUrlWithLinkProperties block"); + CDVPluginResult* pluginResult = nil; + if (!error) { + NSError *err; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{@"url":url} + options:0 + error:&err]; + if (!jsonData) { + NSLog(@"Parsing Error: %@", [err localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[err localizedDescription]]; + } else { + NSLog(@"Success"); + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString]; + } + } + else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} + +- (void)showShareSheet:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start showShareSheet"); + NSString *shareText = nil; + + if ([command.arguments count] >= 3) { + shareText = [command.arguments objectAtIndex:2]; + } + + NSDictionary *arg1 = [command.arguments objectAtIndex:0]; + NSDictionary *arg2 = [command.arguments objectAtIndex:1]; + + BranchLinkProperties *linkProperties = [[BranchLinkProperties alloc] init]; + + for (id key in arg1) { + if ([key isEqualToString:@"duration"]) { + linkProperties.matchDuration = (NSUInteger)[((NSNumber *)[arg1 objectForKey:key]) integerValue]; + } + else { + [linkProperties setValue:[arg1 objectForKey:key] forKey:key]; + } + } + + for (id key in arg2) { + [linkProperties addControlParam:key withValue:[arg1 objectForKey:key]]; + } + + UIActivityItemProvider *itemProvider = [self.branchUniversalObj getBranchActivityItemWithLinkProperties:linkProperties]; + + NSMutableArray *items = [NSMutableArray arrayWithObject:itemProvider]; + if (shareText) { + [items addObject:shareText]; + } + UIActivityViewController *shareViewController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; + + if (linkProperties.controlParams[@"$email_subject"]) { + @try { + [shareViewController setValue:linkProperties.controlParams[@"$email_subject"] forKey:@"subject"]; + } + @catch (NSException *exception) { + NSLog(@"Error: Unable to setValue 'emailSubject' forKey 'subject' on UIActivityViewController."); + } + } + + [self.viewController presentViewController:shareViewController animated:YES completion:nil]; +} + +- (void)listOnSpotlight:(CDVInvokedUrlCommand*)command { + [self.branchUniversalObj listOnSpotlightWithCallback:^(NSString *string, NSError *error) { + NSLog(@"inside listOnSpotlightWithCallback block"); + CDVPluginResult* pluginResult = nil; + if (!error) { + NSError *err; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:@{@"result":string} + options:0 + error:&err]; + if (!jsonData) { + NSLog(@"Parsing Error: %@", [err localizedDescription]); + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[err localizedDescription]]; + } else { + NSLog(@"Success"); + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:jsonString]; + } + } + else { + pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:[error localizedDescription]]; + } + NSLog(@"returning data to js interface.."); + [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId]; + }]; +} + +#pragma mark - URL Methods (not fully implemented YET!) + +- (NSString *)getShortURL:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start getShortURL"); + Branch *branch = [self getInstance]; + return [branch getShortURL]; +} + +- (id)getShortURLWithParams:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start getShortURLWithParams"); + Branch *branch = [self getInstance]; + NSDictionary *params = [command.arguments objectAtIndex:0]; + + return [branch getShortURLWithParams:params]; +} + +- (NSString *)getLongURLWithParams:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start getLongURLWithParams"); + id params = [command.arguments objectAtIndex:0]; + return [[self getInstance] getLongURLWithParams:params]; +} + +- (NSString *)getContentUrlWithParams:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start getLongURLWithParams"); + NSDictionary *params = [command.arguments objectAtIndex:0]; + NSString *channel = [command.arguments objectAtIndex:1]; + + Branch *branch = [self getInstance]; + return [branch getContentUrlWithParams:params andChannel:channel]; +} + +- (void)getBranchActivityItemWithParams:(CDVInvokedUrlCommand*)command +{ + NSLog(@"start getBranchActivityItemWithParams"); + UIActivityItemProvider *provider = [Branch getBranchActivityItemWithParams:[command.arguments objectAtIndex:0]]; + + UIActivityViewController *shareViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ provider ] applicationActivities:nil]; + + [self.viewController presentViewController:shareViewController animated:YES completion:nil]; } @end diff --git a/testbed/www/js/index.js b/testbed/www/js/index.js index f9f56e9c..79d288fc 100644 --- a/testbed/www/js/index.js +++ b/testbed/www/js/index.js @@ -110,7 +110,7 @@ function GetLatestReferringParams() function GetFirstReferringParams() { console.log('Trigger GetFirstReferringParams()'); - + Branch.getFirstReferringParams().then(function (res) { alert('Success: ' + JSON.stringify(res)); console.log(res); diff --git a/www/branch.js b/www/branch.js index 7ae81356..f1afe746 100644 --- a/www/branch.js +++ b/www/branch.js @@ -13,13 +13,13 @@ var _API_CLASS = 'BranchSDK'; // SDK Class * * @param (String) method - The class method to execute * @param (Array) params - Method parameter(s) to pass - * + * * @return (Promise) */ function execute(method, params) { - + params = ( ! params) ? [] : params; - + var self = this; return new Promise(function (resolve, reject) { @@ -45,7 +45,7 @@ var Branch = function () { * @return (Promise) */ Branch.prototype.initSession = function () { - + if (this.debugMode !== null) { return execute('initSession'); } else { @@ -61,7 +61,7 @@ Branch.prototype.initSession = function () { * NOTE: Init session must be called first before using this method * * @param (Boolean) isEnabled. Default = false - * + * * @return (Promise) */ Branch.prototype.setDebug = function (isEnabled) { @@ -71,7 +71,7 @@ Branch.prototype.setDebug = function (isEnabled) { this.debugMode = isEnabled; return execute('setDebug', [isEnabled]); - + }; /** @@ -80,7 +80,7 @@ Branch.prototype.setDebug = function (isEnabled) { * @return (Promise) */ Branch.prototype.getFirstReferringParams = function () { - + return execute('getFirstReferringParams'); }; @@ -91,7 +91,7 @@ Branch.prototype.getFirstReferringParams = function () { * @return (Promise) */ Branch.prototype.getLatestReferringParams = function () { - + return execute('getLatestReferringParams'); }; @@ -102,10 +102,10 @@ Branch.prototype.getLatestReferringParams = function () { * @param (String) identity - A unique identifier for the user [REQUIRED] * * @return (Promise) - * + * */ Branch.prototype.setIdentity = function (identity) { - + if (identity) { return execute('setIdentity', [identity]); } else { @@ -122,7 +122,7 @@ Branch.prototype.setIdentity = function (identity) { * @return (Promise) */ Branch.prototype.logout = function () { - + return execute('logout'); }; @@ -132,11 +132,11 @@ Branch.prototype.logout = function () { * * @param (String) action - Name of the custom action * @param (Object) metaData - Data to pass with the action [OPTIONAL] - * + * * @return (Promise) */ Branch.prototype.userCompletedAction = function (action, metaData) { - + var args = [action]; if (metaData) { @@ -168,7 +168,7 @@ Branch.prototype.userCompletedAction = function (action, metaData) { * -------------------------------------------------------------- */ Branch.prototype.createBranchUniversalObject = function (options) { - + return new Promise(function (resolve, reject) { execute('createBranchUniversalObject', [options]).then(function (res) { @@ -185,7 +185,7 @@ Branch.prototype.createBranchUniversalObject = function (options) { /** * Generates a short url. - * + * * @param (Object) options * @param (Object) controlParameters * @@ -201,7 +201,7 @@ Branch.prototype.createBranchUniversalObject = function (options) { * | stage | String | The link stage | * | duration | Int | The link duration | * -------------------------------------------------- - * + * * controlParameters: * ------------------------------------------------------- * | KEY | TYPE | DESCRIPTION | @@ -227,7 +227,7 @@ Branch.prototype.createBranchUniversalObject = function (options) { * * @param (Object) options * @param (Object) controlParameters - * + * * @return (Promise) * * options: @@ -240,7 +240,7 @@ Branch.prototype.createBranchUniversalObject = function (options) { * | stage | String | The link stage | * | duration | Int | The link duration | * -------------------------------------------------- - * + * * controlParameters: * ------------------------------------------------------- * | KEY | TYPE | DESCRIPTION | @@ -261,15 +261,6 @@ Branch.prototype.createBranchUniversalObject = function (options) { }; - /** - * List item on Spotlight (iOS Only). - */ - res.listOnSpotlight = function () { - - return execute('listOnSpotlight'); - - }; - resolve(res); }, function (err) { @@ -279,13 +270,111 @@ Branch.prototype.createBranchUniversalObject = function (options) { }; +/** + * Register view count. + * + * @return (Promise) + */ +Branch.prototype.registerView = function () { + + return execute('registerView'); + +}; + +/** + * Generates a short url. + * + * @param (Object) options + * @param (Object) controlParameters + * + * @return (Promise) + * + * options: + * -------------------------------------------------- + * | KEY | TYPE | DESCRIPTION | + * -------------------------------------------------- + * | feature | String | The link feature | + * | alias | String | The link alias | + * | channel | String | The link channel | + * | stage | String | The link stage | + * | duration | Int | The link duration | + * -------------------------------------------------- + * + * controlParameters: + * ------------------------------------------------------- + * | KEY | TYPE | DESCRIPTION | + * ------------------------------------------------------- + * | $fallback_url | String | Fallback URL | + * | $desktop_url | String | Desktop URL | + * | $android_url | String | Android URL | + * | $ios_url | String | iOS URL | + * | $ipad_url | String | iPad URL | + * | $fire_url | String | Kindle Fire URL | + * | $blackberry_url | String | Blackberry URL | + * | $windows_phone_url | String | Kindle Fire URL | + * ------------------------------------------------------- + */ +Branch.prototype.generateShortUrl = function (options, controlParameters) { + + return execute('generateShortUrl', [options, controlParameters]); + +}; + +/** + * Show the share dialog. + * + * @param (Object) options + * @param (Object) controlParameters + * + * @return (Promise) + * + * options: + * -------------------------------------------------- + * | KEY | TYPE | DESCRIPTION | + * -------------------------------------------------- + * | feature | String | The link feature | + * | alias | String | The link alias | + * | channel | String | The link channel | + * | stage | String | The link stage | + * | duration | Int | The link duration | + * -------------------------------------------------- + * + * controlParameters: + * ------------------------------------------------------- + * | KEY | TYPE | DESCRIPTION | + * ------------------------------------------------------- + * | $fallback_url | String | Fallback URL | + * | $desktop_url | String | Desktop URL | + * | $android_url | String | Android URL | + * | $ios_url | String | iOS URL | + * | $ipad_url | String | iPad URL | + * | $fire_url | String | Kindle Fire URL | + * | $blackberry_url | String | Blackberry URL | + * | $windows_phone_url | String | Kindle Fire URL | + * ------------------------------------------------------- + */ +Branch.prototype.showShareSheet = function (options, controlParameters) { + + return execute('showShareSheet', [options, controlParameters]); + +}; + +/** + * List item on Spotlight (iOS Only). + */ +Branch.prototype.listOnSpotlight = function () { + + return execute('listOnSpotlight'); + +}; + /** * Retrieve the current reward balance. * * @return (Promise) */ Branch.prototype.loadRewards = function () { - + return execute('loadRewards'); }; @@ -298,7 +387,7 @@ Branch.prototype.loadRewards = function () { * @return (Promise) */ Branch.prototype.redeemRewards = function (value) { - + return execute('redeemRewards', [value]); }; @@ -309,8 +398,8 @@ Branch.prototype.redeemRewards = function (value) { * @return (Promise) */ Branch.prototype.creditHistory = function () { - - return execute('creditHistory'); + + return execute('getCreditHistory'); };