Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Renemari Padillo committed Jul 28, 2016
2 parents 9308592 + 895ff9e commit 1069f6e
Show file tree
Hide file tree
Showing 37 changed files with 146 additions and 1,305 deletions.
4 changes: 4 additions & 0 deletions hooks/lib/android/manifestWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ Class injects plugin preferences into AndroidManifest.xml file.
}]
};

if (!pathPrefix) {
delete intentFilter['data'][0]['$']['android:pathPrefix'];
}

if (!androidM) {
delete intentFilter['$']['android:autoVerify'];
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.1.7",
"version": "2.1.10",
"name": "branch-cordova-sdk",
"description": "Branch Metrics Cordova SDK",
"main": "www/branch.js",
Expand All @@ -19,8 +19,10 @@
"cordova-android",
"branch",
"linking",
"deep links",
"deep linking",
"universal links",
"app links",
"deferred deep linking"
],
"platforms": [
Expand Down
12 changes: 2 additions & 10 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE.
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="io.branch.sdk"
version="2.1.7">
version="2.1.10">

<name>branch-cordova-sdk</name>
<description>Branch SDK Plugin</description>
Expand Down Expand Up @@ -166,18 +166,12 @@ SOFTWARE.
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BNCServerRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BNCServerRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchApplyPromoCodeRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchApplyPromoCodeRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchCloseRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchCloseRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchCreditHistoryRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchCreditHistoryRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchGetPromoCodeRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchGetPromoCodeRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchInstallRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchInstallRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchLoadActionsRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchLoadActionsRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchLoadRewardsRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchLoadRewardsRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchLogoutRequest.h" />
Expand All @@ -197,8 +191,6 @@ SOFTWARE.
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchSpotlightUrlRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchSpotlightUrlRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchUserCompletedActionRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchUserCompletedActionRequest.m" />
<header-file src="src/ios/dependencies/Branch-SDK/Requests/BranchValidatePromoCodeRequest.h" />
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchValidatePromoCodeRequest.m" /> -->
<source-file src="src/ios/dependencies/Branch-SDK/Requests/BranchUserCompletedActionRequest.m" /> -->
</platform>
</plugin>
15 changes: 4 additions & 11 deletions src/ios/BranchSDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,10 @@ - (void)postUnhandledURL:(NSNotification *)notification {
// We create a JSON string result, because we're unable to handle the url. We will include the url in the return string.
NSError *error;
NSString *urlString;

if ([notification.object respondsToSelector:@selector(absoluteString:)]) {

// if ([notification.object respondsToSelector:@selector(absoluteString:)]) {
SEL selector = NSSelectorFromString(@"absoluteString:");
if ([notification.object respondsToSelector:selector]) {
urlString = [notification.object absoluteString];
} else {
urlString = notification.object;
Expand Down Expand Up @@ -633,15 +635,6 @@ - (NSString *)getLongURLWithParams:(CDVInvokedUrlCommand*)command
return [[self getInstance] getLongURLWithParams:params];
}

- (NSString *)getContentUrlWithParams:(CDVInvokedUrlCommand*)command
{
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
{
UIActivityItemProvider *provider = [Branch getBranchActivityItemWithParams:[command.arguments objectAtIndex:0]];
Expand Down
4 changes: 2 additions & 2 deletions 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.3"
#define SDK_VERSION @"0.12.4"

#define BNC_PROD_ENV
//#define BNC_STAGE_ENV
Expand All @@ -20,7 +20,7 @@
#endif

#ifdef BNC_STAGE_ENV
#define BNC_API_BASE_URL @"http://api.dev.branchmetrics.io"
#define BNC_API_BASE_URL @"http://api.dev.branch.io"
#endif

#define BNC_LINK_URL @"https://bnc.lt"
Expand Down
1 change: 0 additions & 1 deletion src/ios/dependencies/Branch-SDK/BNCError.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ FOUNDATION_EXPORT NSString * const BNCErrorDomain;
enum {
BNCInitError = 1000,
BNCDuplicateResourceError,
BNCInvalidPromoCodeError,
BNCRedeemCreditsError,
BNCBadRequestError,
BNCServerProblemError,
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 "../Fabric/Answers.h"
#import "Answers.h"

@implementation BNCFabricAnswers

Expand Down
14 changes: 6 additions & 8 deletions src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
@interface BNCPreferenceHelper : NSObject

@property (strong, nonatomic) NSString *branchKey;
@property (strong, nonatomic) NSString *appKey;
@property (strong, nonatomic) NSString *lastRunBranchKey;
@property (strong, nonatomic) NSDate *lastStrongMatchDate;
@property (strong, nonatomic) NSString *appVersion;
Expand All @@ -28,8 +27,6 @@
@property (strong, nonatomic) NSString *userIdentity;
@property (strong, nonatomic) NSString *sessionParams;
@property (strong, nonatomic) NSString *installParams;
@property (assign, nonatomic) BOOL explicitlyRequestedReferrable;
@property (assign, nonatomic) BOOL isReferrable;
@property (assign, nonatomic) BOOL isDebug;
@property (assign, nonatomic) BOOL shouldWaitForInit;
@property (assign, nonatomic) BOOL suppressWarningLogs;
Expand All @@ -43,6 +40,8 @@

- (NSString *)getAPIBaseURL;
- (NSString *)getAPIURL:(NSString *)endpoint;
- (NSString *)getEndpointFromURL:(NSString *)url;

- (NSString *)getBranchKey:(BOOL)isLive;

- (void)clearUserCreditsAndCounts;
Expand All @@ -57,17 +56,16 @@
- (NSInteger)getCreditCount;
- (NSInteger)getCreditCountForBucket:(NSString *)bucket;

- (void)setActionTotalCount:(NSString *)action withCount:(NSInteger)count;
- (void)setActionUniqueCount:(NSString *)action withCount:(NSInteger)count;
- (NSInteger)getActionTotalCount:(NSString *)action;
- (NSInteger)getActionUniqueCount:(NSString *)action;

- (void)updateBranchViewCount:(NSString *)branchViewID;
- (NSInteger)getBranchViewCount:(NSString *)branchViewID;

- (void)setRequestMetadataKey:(NSString *)key value:(NSObject *)value;
- (NSMutableDictionary *)requestMetadataDictionary;

- (void)addInstrumentationDictionaryKey:(NSString *)key value:(NSString *)value;
- (NSMutableDictionary *)instrumentationDictionary;
- (void)clearInstrumentationDictionary;

- (void)log:(NSString *)filename line:(int)line message:(NSString *)format, ...;
- (void)logWarning:(NSString *)message;
@end
111 changes: 28 additions & 83 deletions src/ios/dependencies/Branch-SDK/BNCPreferenceHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#import "BNCEncodingUtils.h"
#import "BNCConfig.h"
#import "Branch.h"
#import "../Fabric/Fabric+FABKits.h"
#import "Fabric+FABKits.h"

static const NSTimeInterval DEFAULT_TIMEOUT = 5.5;
static const NSTimeInterval DEFAULT_RETRY_INTERVAL = 0;
static const NSInteger DEFAULT_RETRY_COUNT = 3;

NSString * const BRANCH_PREFS_FILE = @"BNCPreferences";

NSString * const BRANCH_PREFS_KEY_APP_KEY = @"bnc_app_key";
NSString * const BRANCH_PREFS_KEY_APP_VERSION = @"bnc_app_version";
NSString * const BRANCH_PREFS_KEY_LAST_RUN_BRANCH_KEY = @"bnc_last_run_branch_key";
NSString * const BRANCH_PREFS_KEY_LAST_STRONG_MATCH_DATE = @"bnc_strong_match_created_date";
Expand All @@ -33,17 +32,12 @@
NSString * const BRANCH_PREFS_KEY_SESSION_PARAMS = @"bnc_session_params";
NSString * const BRANCH_PREFS_KEY_INSTALL_PARAMS = @"bnc_install_params";
NSString * const BRANCH_PREFS_KEY_USER_URL = @"bnc_user_url";
NSString * const BRANCH_PREFS_KEY_IS_REFERRABLE = @"bnc_is_referrable";
NSString * const BRANCH_PREFS_KEY_BRANCH_UNIVERSAL_LINK_DOMAINS = @"branch_universal_link_domains";
NSString * const BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI = @"external_intent_uri";

NSString * const BRANCH_PREFS_KEY_CREDITS = @"bnc_credits";
NSString * const BRANCH_PREFS_KEY_CREDIT_BASE = @"bnc_credit_base_";

NSString * const BRANCH_PREFS_KEY_COUNTS = @"bnc_counts";
NSString * const BRANCH_PREFS_KEY_TOTAL_BASE = @"bnc_total_base_";
NSString * const BRANCH_PREFS_KEY_UNIQUE_BASE = @"bnc_unique_base_";

NSString * const BRANCH_PREFS_KEY_BRANCH_VIEW_USAGE_CNT = @"bnc_branch_view_usage_cnt_";

// The name of this key was specified in the account-creation API integration
Expand All @@ -52,17 +46,16 @@
@interface BNCPreferenceHelper ()

@property (strong, nonatomic) NSMutableDictionary *persistenceDict;
@property (strong, nonatomic) NSMutableDictionary *countsDictionary;
@property (strong, nonatomic) NSMutableDictionary *creditsDictionary;
@property (strong, nonatomic) NSMutableDictionary *requestMetadataDictionary;
@property (strong, nonatomic) NSMutableDictionary *instrumentationDictionary;
@property (assign, nonatomic) BOOL isUsingLiveKey;

@end

@implementation BNCPreferenceHelper

@synthesize branchKey = _branchKey,
appKey = _appKey,
lastRunBranchKey = _lastRunBranchKey,
appVersion = _appVersion,
deviceFingerprintID = _deviceFingerprintID,
Expand All @@ -76,7 +69,6 @@ @implementation BNCPreferenceHelper
installParams = _installParams,
universalLinkUrl = _universalLinkUrl,
externalIntentURI = _externalIntentURI,
isReferrable = _isReferrable,
isDebug = _isDebug,
shouldWaitForInit = _shouldWaitForInit,
suppressWarningLogs = _suppressWarningLogs,
Expand All @@ -85,7 +77,8 @@ @implementation BNCPreferenceHelper
timeout = _timeout,
lastStrongMatchDate = _lastStrongMatchDate,
checkedFacebookAppLinks = _checkedFacebookAppLinks,
requestMetadataDictionary = _requestMetadataDictionary;
requestMetadataDictionary = _requestMetadataDictionary,
instrumentationDictionary = _instrumentationDictionary;

+ (BNCPreferenceHelper *)preferenceHelper {
static BNCPreferenceHelper *preferenceHelper;
Expand All @@ -106,8 +99,6 @@ - (id)init {

_isDebug = NO;
_suppressWarningLogs = NO;
_explicitlyRequestedReferrable = NO;
_isReferrable = [self readBoolFromDefaults:BRANCH_PREFS_KEY_IS_REFERRABLE];
}

return self;
Expand Down Expand Up @@ -162,24 +153,11 @@ - (NSString *)getAPIURL:(NSString *) endpoint {
return [[self getAPIBaseURL] stringByAppendingString:endpoint];
}

#pragma mark - Preference Storage

- (NSString *)appKey {
if (!_appKey) {
_appKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:BRANCH_PREFS_KEY_APP_KEY];
}

return _appKey;
}

- (void)setAppKey:(NSString *)appKey {
NSLog(@"Usage of App Key is deprecated, please move toward using a Branch key");

if (![_appKey isEqualToString:appKey]) {
_appKey = appKey;
[self writeObjectToDefaults:BRANCH_PREFS_KEY_APP_KEY value:appKey];
}
- (NSString *)getEndpointFromURL:(NSString *)url {
NSUInteger index = BNC_API_BASE_URL.length;
return [url substringFromIndex:index];
}
#pragma mark - Preference Storage

- (NSString *)getBranchKey:(BOOL)isLive {
// Already loaded a key, and it's the same state (live/test)
Expand Down Expand Up @@ -448,29 +426,8 @@ - (void)setCheckedFacebookAppLinks:(BOOL)checked {
[self writeBoolToDefaults:BRANCH_PREFS_KEY_CHECKED_FACEBOOK_APP_LINKS value:checked];
}

- (BOOL)isReferrable {
BOOL hasIdentity = self.identityID != nil;

// If referrable is set, but they already have an identity, they should only
// still be referrable if the dev has explicitly set always referrable.
if (_isReferrable && hasIdentity) {
return _explicitlyRequestedReferrable;
}

// If not referrable, or no identity yet, whatever isReferrable has is fine to return.
return _isReferrable;
}

- (void)setIsReferrable:(BOOL)isReferrable {
if (_isReferrable != isReferrable) {
_isReferrable = isReferrable;
[self writeBoolToDefaults:BRANCH_PREFS_KEY_IS_REFERRABLE value:isReferrable];
}
}

- (void)clearUserCreditsAndCounts {
self.creditsDictionary = [[NSMutableDictionary alloc] init];
self.countsDictionary = [[NSMutableDictionary alloc] init];
}

- (id)getBranchUniversalLinkDomains {
Expand All @@ -496,6 +453,26 @@ - (void)setRequestMetadataKey:(NSString *)key value:(NSObject *)value {
}
}

- (NSMutableDictionary *)instrumentationDictionary {
if (!_instrumentationDictionary) {
_instrumentationDictionary = [NSMutableDictionary dictionary];
}
return _instrumentationDictionary;
}

- (void)addInstrumentationDictionaryKey:(NSString *)key value:(NSString *)value {
if (key && value) {
[self.instrumentationDictionary setObject:value forKey:key];
}
}

- (void)clearInstrumentationDictionary {
NSArray *keys = [_instrumentationDictionary allKeys];
for (int i = 0 ; i < [keys count]; i++) {
[_instrumentationDictionary removeObjectForKey:keys[i]];
}
}

#pragma mark - Credit Storage

- (NSMutableDictionary *)creditsDictionary {
Expand Down Expand Up @@ -552,38 +529,6 @@ - (void)clearUserCredits {

#pragma mark - Count Storage

- (NSMutableDictionary *)countsDictionary {
if (!_countsDictionary) {
_countsDictionary = [[self readObjectFromDefaults:BRANCH_PREFS_KEY_COUNTS] mutableCopy];

if (!_countsDictionary) {
_countsDictionary = [[NSMutableDictionary alloc] init];
}
}

return _countsDictionary;
}

- (void)setActionTotalCount:(NSString *)action withCount:(NSInteger)count {
self.countsDictionary[[BRANCH_PREFS_KEY_TOTAL_BASE stringByAppendingString:action]] = @(count);

[self writeObjectToDefaults:BRANCH_PREFS_KEY_COUNTS value:self.countsDictionary];
}

- (void)setActionUniqueCount:(NSString *)action withCount:(NSInteger)count {
self.countsDictionary[[BRANCH_PREFS_KEY_UNIQUE_BASE stringByAppendingString:action]] = @(count);

[self writeObjectToDefaults:BRANCH_PREFS_KEY_COUNTS value:self.countsDictionary];
}

- (NSInteger)getActionTotalCount:(NSString *)action {
return [self.countsDictionary[[BRANCH_PREFS_KEY_TOTAL_BASE stringByAppendingString:action]] integerValue];
}

- (NSInteger)getActionUniqueCount:(NSString *)action {
return [self.countsDictionary[[BRANCH_PREFS_KEY_UNIQUE_BASE stringByAppendingString:action]] integerValue];
}

- (void)updateBranchViewCount:(NSString *)branchViewID {
NSInteger currentCount = [self getBranchViewCount:branchViewID] + 1;
[self writeObjectToDefaults:[BRANCH_PREFS_KEY_BRANCH_VIEW_USAGE_CNT stringByAppendingString:branchViewID] value:@(currentCount)];
Expand Down
5 changes: 0 additions & 5 deletions src/ios/dependencies/Branch-SDK/BNCServerInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@

typedef void (^BNCServerCallback)(BNCServerResponse *response, NSError *error);

static NSString *REQ_TAG_DEBUG_CONNECT = @"t_debug_connect";
static NSString *REQ_TAG_DEBUG_LOG = @"t_debug_log";
static NSString *REQ_TAG_DEBUG_SCREEN = @"t_debug_screen";
static NSString *REQ_TAG_DEBUG_DISCONNECT = @"t_debug_disconnect";

@interface BNCServerInterface : NSObject

@property (strong, nonatomic) BNCPreferenceHelper *preferenceHelper;
Expand Down
Loading

0 comments on commit 1069f6e

Please sign in to comment.