Skip to content

Commit 453aebc

Browse files
author
Dan Walkowski
committed
Merge pull request #263 from BranchMetrics/deep-link-debug-data
implemented debug params, (aka: 100% match?)
2 parents 2312d1b + 24f0a65 commit 453aebc

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

Branch-SDK/Branch-SDK/Branch.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ typedef NS_ENUM(NSUInteger, BranchPromoCodeUsageType) {
439439
*/
440440
+ (void)setDebug __attribute__((deprecated(("Use the instance method instead"))));
441441

442+
/**
443+
Specify additional constant parameters to be included in the response
444+
445+
@param debugParams dictionary of keystrings/valuestrings that will be added to response
446+
*/
447+
-(void) setDeepLinkDebugMode:(NSDictionary *)debugParams;
448+
449+
442450
/**
443451
Specify the time to wait in seconds between retries in the case of a Branch server error
444452

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ @interface Branch() <UIGestureRecognizerDelegate, BranchDeepLinkingControllerCom
8686
@property (strong, nonatomic) NSMutableDictionary *deepLinkControllers;
8787
@property (weak, nonatomic) UIViewController *deepLinkPresentingController;
8888
@property (assign, nonatomic) BOOL useCookieBasedMatching;
89+
@property (strong, nonatomic) NSDictionary *deepLinkDebugParams;
8990
@property (assign, nonatomic) BOOL accountForFacebookSDK;
9091

92+
9193
@end
9294

9395
@implementation Branch
@@ -383,6 +385,14 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)
383385
}
384386
}
385387

388+
389+
390+
//these params will be added
391+
- (void) setDeepLinkDebugMode:(NSDictionary *)debugParams {
392+
self.deepLinkDebugParams = debugParams;
393+
}
394+
395+
386396
- (BOOL)handleDeepLink:(NSURL *)url {
387397
BOOL handled = NO;
388398
if (url) {
@@ -410,7 +420,6 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
410420
//check to see if a browser activity needs to be handled
411421
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
412422
self.preferenceHelper.universalLinkUrl = [userActivity.webpageURL absoluteString];
413-
414423
[self initUserSessionAndCallCallback:YES];
415424
self.preferenceHelper.isContinuingUserActivity = NO;
416425

@@ -668,11 +677,25 @@ - (BranchLinkProperties *)getFirstReferringBranchLinkProperties {
668677
}
669678

670679
- (NSDictionary *)getFirstReferringParams {
671-
return [BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.installParams];
680+
NSDictionary *origInstallParams = [BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.installParams];
681+
682+
if (self.deepLinkDebugParams) {
683+
NSMutableDictionary* debugInstallParams = [[BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams] mutableCopy];
684+
[debugInstallParams addEntriesFromDictionary:self.deepLinkDebugParams];
685+
return debugInstallParams;
686+
}
687+
return origInstallParams;
672688
}
673689

674690
- (NSDictionary *)getLatestReferringParams {
675-
return [BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams];
691+
NSDictionary *origSessionParams = [BNCEncodingUtils decodeJsonStringToDictionary:self.preferenceHelper.sessionParams];
692+
693+
if (self.deepLinkDebugParams) {
694+
NSMutableDictionary* debugSessionParams = [origSessionParams mutableCopy];
695+
[debugSessionParams addEntriesFromDictionary:self.deepLinkDebugParams];
696+
return debugSessionParams;
697+
}
698+
return origSessionParams;
676699
}
677700

678701
- (BranchUniversalObject *)getLatestReferringBranchUniversalObject {

Branch-TestBed/Branch-TestBed/AppDelegate.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
3333
Branch *branch = [Branch getInstance];
3434
[branch setDebug];
3535

36+
[branch setDeepLinkDebugMode:@{@"example_debug_param" : @"foo"}];
37+
3638
[branch registerDeepLinkController:controller forKey:@"gravatar_email"];
3739

3840
[branch initSessionWithLaunchOptions:launchOptions automaticallyDisplayDeepLinkController:YES deepLinkHandler:^(NSDictionary *params, NSError *error) {

0 commit comments

Comments
 (0)