Skip to content

Commit b8f95e6

Browse files
committed
CORE-1950 backport install referrer
1 parent 3d7aa5f commit b8f95e6

File tree

7 files changed

+21
-1
lines changed

7 files changed

+21
-1
lines changed

Branch-SDK/BNCPreferenceHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ NSURL* /* _Nonnull */ BNCURLForBranchDirectory(void);
2828
@property (strong, nonatomic) NSString *linkClickIdentifier;
2929
@property (strong, nonatomic) NSString *spotlightIdentifier;
3030
@property (strong, atomic) NSString *universalLinkUrl;
31+
@property (strong, atomic) NSString *initialReferrer;
3132
@property (strong, nonatomic) NSString *userUrl;
3233
@property (strong, nonatomic) NSString *userIdentity;
3334
@property (strong, nonatomic) NSString *sessionParams;

Branch-SDK/BNCPreferenceHelper.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
static NSString * const BRANCH_PREFS_KEY_LINK_CLICK_IDENTIFIER = @"bnc_link_click_identifier";
3434
static NSString * const BRANCH_PREFS_KEY_SPOTLIGHT_IDENTIFIER = @"bnc_spotlight_identifier";
3535
static NSString * const BRANCH_PREFS_KEY_UNIVERSAL_LINK_URL = @"bnc_universal_link_url";
36+
static NSString * const BRANCH_PREFS_KEY_INITIAL_REFERRER = @"bnc_initial_referrer";
3637
static NSString * const BRANCH_PREFS_KEY_SESSION_PARAMS = @"bnc_session_params";
3738
static NSString * const BRANCH_PREFS_KEY_INSTALL_PARAMS = @"bnc_install_params";
3839
static NSString * const BRANCH_PREFS_KEY_USER_URL = @"bnc_user_url";
@@ -75,6 +76,7 @@ @implementation BNCPreferenceHelper
7576
sessionParams = _sessionParams,
7677
installParams = _installParams,
7778
universalLinkUrl = _universalLinkUrl,
79+
initialReferrer = _initialReferrer,
7880
externalIntentURI = _externalIntentURI,
7981
isDebug = _isDebug,
8082
retryCount = _retryCount,
@@ -315,6 +317,13 @@ - (void)setUniversalLinkUrl:(NSString *)universalLinkUrl {
315317
[self writeObjectToDefaults:BRANCH_PREFS_KEY_UNIVERSAL_LINK_URL value:universalLinkUrl];
316318
}
317319

320+
- (NSString *)initialReferrer {
321+
return [self readStringFromDefaults:BRANCH_REQUEST_KEY_INITIAL_REFERRER];
322+
}
323+
324+
- (void)setInitialReferrer:(NSString *)initialReferrer {
325+
[self writeObjectToDefaults:BRANCH_REQUEST_KEY_INITIAL_REFERRER value:initialReferrer];
326+
}
318327
- (NSString *)sessionParams {
319328
@synchronized (self) {
320329
if (!_sessionParams) {
@@ -659,6 +668,7 @@ - (void) clearTrackingInformation {
659668
self.spotlightIdentifier = nil;
660669
self.referringURL = nil;
661670
self.universalLinkUrl = nil;
671+
self.initialReferrer = nil;
662672
self.installParams = nil;
663673
self.appleSearchAdDetails = nil;
664674
self.appleSearchAdNeedsSend = NO;

Branch-SDK/Branch.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,12 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
811811
- (BOOL)continueUserActivity:(NSUserActivity *)userActivity sceneIdentifier:(NSString *)sceneIdentifier {
812812
BNCLogDebugSDK(@"continueUserActivity:");
813813

814+
if (@available(iOS 11.0, *)) {
815+
if (userActivity.referrerURL) {
816+
self.preferenceHelper.initialReferrer = userActivity.referrerURL.absoluteString;
817+
}
818+
}
819+
814820
// Check to see if a browser activity needs to be handled
815821
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
816822
return [self handleDeepLink:userActivity.webpageURL sceneIdentifier:sceneIdentifier];

Branch-SDK/BranchConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ extern NSString * const BRANCH_REQUEST_KEY_LINK_IDENTIFIER;
6060
extern NSString * const BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER;
6161
extern NSString * const BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL;
6262
extern NSString * const BRANCH_REQUEST_KEY_LOCAL_URL;
63+
extern NSString * const BRANCH_REQUEST_KEY_INITIAL_REFERRER;
6364
extern NSString * const BRANCH_REQUEST_KEY_BRAND;
6465
extern NSString * const BRANCH_REQUEST_KEY_MODEL;
6566
extern NSString * const BRANCH_REQUEST_KEY_SCREEN_WIDTH;

Branch-SDK/BranchConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
NSString * const BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER = @"spotlight_identifier";
5757
NSString * const BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL = @"universal_link_url";
5858
NSString * const BRANCH_REQUEST_KEY_LOCAL_URL = @"local_url";
59+
NSString * const BRANCH_REQUEST_KEY_INITIAL_REFERRER = @"initial_referrer";
5960
NSString * const BRANCH_REQUEST_KEY_BRAND = @"brand";
6061
NSString * const BRANCH_REQUEST_KEY_MODEL = @"model";
6162
NSString * const BRANCH_REQUEST_KEY_SCREEN_WIDTH = @"screen_width";

Branch-SDK/BranchInstallRequest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca
3838
[self safeSetValue:preferenceHelper.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:params];
3939
[self safeSetValue:preferenceHelper.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:params];
4040
[self safeSetValue:preferenceHelper.universalLinkUrl forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:params];
41-
41+
[self safeSetValue:preferenceHelper.initialReferrer forKey:BRANCH_REQUEST_KEY_INITIAL_REFERRER onDict:params];
4242
[self safeSetValue:[[BNCAppleReceipt sharedInstance] installReceipt] forKey:BRANCH_REQUEST_KEY_APPLE_RECEIPT onDict:params];
4343
[self safeSetValue:[NSNumber numberWithBool:[[BNCAppleReceipt sharedInstance] isTestFlight]] forKey:BRANCH_REQUEST_KEY_APPLE_TESTFLIGHT onDict:params];
4444

Branch-SDK/BranchOpenRequest.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ - (void)makeRequest:(BNCServerInterface *)serverInterface key:(NSString *)key ca
6464
[self safeSetValue:preferenceHelper.linkClickIdentifier forKey:BRANCH_REQUEST_KEY_LINK_IDENTIFIER onDict:params];
6565
[self safeSetValue:preferenceHelper.spotlightIdentifier forKey:BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER onDict:params];
6666
[self safeSetValue:preferenceHelper.universalLinkUrl forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:params];
67+
[self safeSetValue:preferenceHelper.initialReferrer forKey:BRANCH_REQUEST_KEY_INITIAL_REFERRER onDict:params];
6768
[self safeSetValue:preferenceHelper.externalIntentURI forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:params];
6869
if (preferenceHelper.limitFacebookTracking)
6970
params[@"limit_facebook_tracking"] = (__bridge NSNumber*) kCFBooleanTrue;

0 commit comments

Comments
 (0)