Skip to content

Commit

Permalink
[CHORE] Updated native SDKs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Renemari Padillo committed Aug 9, 2016
1 parent 132bb7b commit dd4fc65
Show file tree
Hide file tree
Showing 19 changed files with 493 additions and 13 deletions.
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ SOFTWARE.
</intent-filter>
</config-file>
<source-file src="src/android/io/branch/BranchSDK.java" target-dir="src/io/branch" />
<framework src="io.branch.sdk.android:library:1+" />
<framework src="io.branch.sdk.android:library:2+" />
</platform>

<!-- ios -->
Expand Down
2 changes: 1 addition & 1 deletion src/android/io/branch/BranchSDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ public void run() {
if (this.args.length() == 1) {
loadRewards(this.args.getString(0), this.callbackContext);
} else {
loadRewards(this.callbackContext);
loadRewards(this.callbackContext);
}
} else if (this.action.equals("redeemRewards")) {
if (this.args.length() == 1) {
Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef Branch_SDK_Config_h
#define Branch_SDK_Config_h

#define SDK_VERSION @"0.12.4"
#define SDK_VERSION @"0.12.5"

#define BNC_PROD_ENV
//#define BNC_STAGE_ENV
Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCFabricAnswers.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "BNCFabricAnswers.h"
#import "BNCPreferenceHelper.h"
#import "Answers.h"
#import "../Fabric/Answers.h"

@implementation BNCFabricAnswers

Expand Down
2 changes: 1 addition & 1 deletion src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "BNCEncodingUtils.h"
#import "BNCConfig.h"
#import "Branch.h"
#import "Fabric+FABKits.h"
#import "../Fabric/Fabric+FABKits.h"

static const NSTimeInterval DEFAULT_TIMEOUT = 5.5;
static const NSTimeInterval DEFAULT_RETRY_INTERVAL = 0;
Expand Down
27 changes: 25 additions & 2 deletions src/ios/dependencies/Branch-SDK/Branch.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,19 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
*/
-(void)setDeepLinkDebugMode:(NSDictionary *)debugParams;

/**
Add a scheme to a whitelist of URI schemes that will be tracked by Branch. Default to all schemes.
@param the scheme to add to the whitelist, i.e. @"http", @"https" or @"myapp"
*/
-(void)addWhiteListedScheme:(NSString *)scheme;

/**
Add an array of schemes to a whitelist of URI schemes that will be tracked by Branch. Default to all schemes.
@param the array of schemes to add to the whitelist, i.e. @[@"http", @"https", @"myapp"]
*/
-(void)setWhiteListedSchemes:(NSArray *)schemes;

/**
Register your Facebook SDK's FBSDKAppLinkUtility class to be used by Branch for deferred deep linking from their platform
Expand Down Expand Up @@ -394,8 +407,18 @@ typedef NS_ENUM(NSUInteger, BranchCreditHistoryOrder) {
- (void)disableCookieBasedMatching;

/**
If you're using a version of the Facebook SDK that prevents application:didFinishLaunchingWithOptions: from returning
YES/true when a Universal Link is clicked, you should enable this option.
TL;DR: If you're using a version of the Facebook SDK that prevents application:didFinishLaunchingWithOptions: from
returning YES/true when a Universal Link is clicked, you should enable this option.
Long explanation: in application:didFinishLaunchingWithOptions: you should choose one of the following:
1. Always `return YES;`, and do *not* invoke `[[Branch getInstance] accountForFacebookSDKPreventingAppLaunch];`
2. Allow the Facebook SDK to determine whether `application:didFinishLaunchingWithOptions:` returns `YES` or `NO`,
and invoke `[[Branch getInstance] accountForFacebookSDKPreventingAppLaunch];`
The reason for this second option is that the Facebook SDK will return `NO` if a Universal Link opens the app
but that UL is not a Facebook UL. Some developers prefer not to modify
`application:didFinishLaunchingWithOptions:` to always return `YES` and should use this method instead.
*/
- (void)accountForFacebookSDKPreventingAppLaunch;

Expand Down
29 changes: 24 additions & 5 deletions src/ios/dependencies/Branch-SDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
#import "BranchRegisterViewRequest.h"

//Fabric
#import "FABKitProtocol.h"
#import "Fabric+FABKits.h"
#import "../Fabric/FABKitProtocol.h"
#import "../Fabric/Fabric+FABKits.h"

NSString * const BRANCH_FEATURE_TAG_SHARE = @"share";
NSString * const BRANCH_FEATURE_TAG_REFERRAL = @"referral";
Expand Down Expand Up @@ -80,6 +80,7 @@ @interface Branch() <BranchDeepLinkingControllerCompletionDelegate, FABKit>
@property (strong, nonatomic) NSDictionary *deepLinkDebugParams;
@property (assign, nonatomic) BOOL accountForFacebookSDK;
@property (assign, nonatomic) id FBSDKAppLinkUtility;
@property (strong, nonatomic) NSMutableArray *whiteListedSchemeList;

@end

Expand Down Expand Up @@ -147,6 +148,7 @@ - (id)initWithInterface:(BNCServerInterface *)interface queue:(BNCServerRequestQ
_processing_sema = dispatch_semaphore_create(1);
_networkCount = 0;
_deepLinkControllers = [[NSMutableDictionary alloc] init];
_whiteListedSchemeList = [[NSMutableArray alloc] init];
_useCookieBasedMatching = YES;

NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
Expand Down Expand Up @@ -320,12 +322,29 @@ - (void) setDeepLinkDebugMode:(NSDictionary *)debugParams {
self.deepLinkDebugParams = debugParams;
}

-(void)setWhiteListedSchemes:(NSArray *)schemes {
self.whiteListedSchemeList = [schemes mutableCopy];
}

-(void)addWhiteListedScheme:(NSString *)scheme {
[self.whiteListedSchemeList addObject:scheme];
}

- (BOOL)handleDeepLink:(NSURL *)url {
BOOL handled = NO;
if (url && ![url isEqual:[NSNull null]]) {
//always save the incoming url in the preferenceHelper in the externalIntentURI field
self.preferenceHelper.externalIntentURI = [url absoluteString];

// save the incoming url in the preferenceHelper in the externalIntentURI field
if ([self.whiteListedSchemeList count]) {
for (NSString *scheme in self.whiteListedSchemeList) {
if ([scheme isEqualToString:[url scheme]]) {
self.preferenceHelper.externalIntentURI = [url absoluteString];
break;
}
}
} else {
self.preferenceHelper.externalIntentURI = [url absoluteString];
}

NSString *query = [url fragment];
if (!query) {
Expand Down Expand Up @@ -1284,7 +1303,7 @@ + (NSString *)bundleIdentifier {
}

+ (NSString *)kitDisplayVersion {
return @"0.12.4";
return @"0.12.5";
}

@end
15 changes: 15 additions & 0 deletions src/ios/dependencies/Branch-SDK/BranchSDK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Created by Ahmed Nawar on 2/24/16.
// Copyright © 2016 Ahmed Nawar. All rights reserved.
// Umbrella header file

#import <UIKit/UIKit.h>

#import "Branch.h"
#import "BNCConfig.h"
#import "BranchView.h"
#import "BranchViewHandler.h"
#import "BranchLinkProperties.h"
#import "BranchUniversalObject.h"
#import "BranchActivityItemProvider.h"
#import "BranchDeepLinkingController.h"
#import "BranchCSSearchableItemAttributeSet.h"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// BranchApplyPromoCodeRequest.h
// Branch-TestBed
//
// Created by Graham Mueller on 5/26/15.
// Copyright (c) 2015 Branch Metrics. All rights reserved.
//

#import "BNCServerRequest.h"
#import "Branch.h"

@interface BranchApplyPromoCodeRequest : BNCServerRequest

- (id)initWithCode:(NSString *)code useOld:(BOOL)useOld callback:(callbackWithParams)callback;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
// BranchApplyPromoCodeRequest.m
// Branch-TestBed
//
// Created by Graham Mueller on 5/26/15.
// Copyright (c) 2015 Branch Metrics. All rights reserved.
//

#import "BranchApplyPromoCodeRequest.h"
#import "BNCPreferenceHelper.h"
#import "BNCError.h"
#import "BranchConstants.h"

@interface BranchApplyPromoCodeRequest ()

@property (strong, nonatomic) NSString *code;
@property (strong, nonatomic) callbackWithParams callback;
@property (assign, nonatomic) BOOL useOld;

@end

@implementation BranchApplyPromoCodeRequest

- (id)initWithCode:(NSString *)code useOld:(BOOL)useOld callback:(callbackWithParams)callback {
if (self = [super init]) {
_code = code;
_callback = callback;
_useOld = useOld;
}

return self;
}

- (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key callback:(BNCServerCallback)callback {
BNCPreferenceHelper *preferenceHelper = [BNCPreferenceHelper preferenceHelper];
NSDictionary *params = @{
BRANCH_REQUEST_KEY_BRANCH_IDENTITY: preferenceHelper.identityID,
BRANCH_REQUEST_KEY_DEVICE_FINGERPRINT_ID: preferenceHelper.deviceFingerprintID,
BRANCH_REQUEST_KEY_SESSION_ID: preferenceHelper.sessionID
};

NSString *endpoint = self.useOld ? BRANCH_REQUEST_ENDPOINT_APPLY_REFERRAL_CODE : BRANCH_REQUEST_ENDPOINT_APPLY_PROMO_CODE;
NSString *url = [NSString stringWithFormat:@"%@/%@", [preferenceHelper getAPIURL:endpoint], self.code];
[serverInterface postRequest:params url:url key:key callback:callback];
}

- (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
if (error) {
if (self.callback) {
self.callback(nil, error);
}
return;
}

NSString *codeKey = self.useOld ? BRANCH_RESPONSE_KEY_REFERRAL_CODE : BRANCH_RESPONSE_KEY_PROMO_CODE;
if (!response.data[codeKey]) {
error = [NSError errorWithDomain:BNCErrorDomain code:BNCInvalidPromoCodeError userInfo:@{ NSLocalizedDescriptionKey: @"Promo code is invalid - it may have already been used or the code might not exist" }];
}

if (self.callback) {
self.callback(response.data, error);
}
}

#pragma mark - NSCoding methods

- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super initWithCoder:decoder]) {
_code = [decoder decodeObjectForKey:@"code"];
_useOld = [decoder decodeBoolForKey:@"useOld"];
}

return self;
}

- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];

[coder encodeObject:self.code forKey:@"code"];
[coder encodeBool:self.useOld forKey:@"useOld"];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// BranchGetPromoCodeRequest.h
// Branch-TestBed
//
// Created by Graham Mueller on 5/26/15.
// Copyright (c) 2015 Branch Metrics. All rights reserved.
//

#import "BNCServerRequest.h"
#import "Branch.h"

@interface BranchGetPromoCodeRequest : BNCServerRequest

- (id)initWithUsageType:(BranchPromoCodeUsageType)usageType rewardLocation:(BranchPromoCodeRewardLocation)rewardLocation amount:(NSInteger)amount bucket:(NSString *)bucket prefix:(NSString *)prefix expiration:(NSDate *)expiration useOld:(BOOL)useOld callback:(callbackWithParams)callback;

@end
Loading

0 comments on commit dd4fc65

Please sign in to comment.