Skip to content

Commit a71fc56

Browse files
author
Dan Walkowski
committed
Merge pull request #259 from BranchMetrics/external-intent-uri
* implemented externalIntentURI
2 parents 3fe89f6 + 4a43e7d commit a71fc56

File tree

6 files changed

+29
-5
lines changed

6 files changed

+29
-5
lines changed

Branch-SDK/Branch-SDK/BNCPreferenceHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
@property (assign, nonatomic) NSInteger retryCount;
3737
@property (assign, nonatomic) NSTimeInterval retryInterval;
3838
@property (assign, nonatomic) NSTimeInterval timeout;
39+
@property (strong, nonatomic) NSString *externalIntentURI;
3940

4041
+ (BNCPreferenceHelper *)preferenceHelper;
4142

Branch-SDK/Branch-SDK/BNCPreferenceHelper.m

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
NSString * const BRANCH_PREFS_KEY_USER_URL = @"bnc_user_url";
3333
NSString * const BRANCH_PREFS_KEY_IS_REFERRABLE = @"bnc_is_referrable";
3434
NSString * const BRANCH_PREFS_KEY_BRANCH_UNIVERSAL_LINK_DOMAINS = @"branch_universal_link_domains";
35+
NSString * const BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI = @"external_intent_uri";
3536

3637
NSString * const BRANCH_PREFS_KEY_CREDITS = @"bnc_credits";
3738
NSString * const BRANCH_PREFS_KEY_CREDIT_BASE = @"bnc_credit_base_";
@@ -52,7 +53,7 @@ @interface BNCPreferenceHelper ()
5253
@implementation BNCPreferenceHelper
5354

5455
@synthesize branchKey = _branchKey, appKey = _appKey, lastRunBranchKey = _lastRunBranchKey, appVersion = _appVersion, deviceFingerprintID = _deviceFingerprintID, sessionID = _sessionID, spotlightIdentifier = _spotlightIdentifier,
55-
identityID = _identityID, linkClickIdentifier = _linkClickIdentifier, userUrl = _userUrl, userIdentity = _userIdentity, sessionParams = _sessionParams, installParams = _installParams, universalLinkUrl = _universalLinkUrl,
56+
identityID = _identityID, linkClickIdentifier = _linkClickIdentifier, userUrl = _userUrl, userIdentity = _userIdentity, sessionParams = _sessionParams, installParams = _installParams, universalLinkUrl = _universalLinkUrl, externalIntentURI = _externalIntentURI,
5657
isReferrable = _isReferrable, isDebug = _isDebug, isConnectedToRemoteDebug = _isConnectedToRemoteDebug, isContinuingUserActivity = _isContinuingUserActivity, retryCount = _retryCount, retryInterval = _retryInterval, timeout = _timeout, lastStrongMatchDate = _lastStrongMatchDate;
5758

5859
+ (BNCPreferenceHelper *)preferenceHelper {
@@ -307,6 +308,20 @@ - (void)setSpotlightIdentifier:(NSString *)spotlightIdentifier {
307308
}
308309
}
309310

311+
- (NSString *)externalIntentURI {
312+
if (!_externalIntentURI) {
313+
_externalIntentURI = [self readStringFromDefaults:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI];
314+
}
315+
return _externalIntentURI;
316+
}
317+
318+
- (void)setExternalIntentURI:(NSString *)externalIntentURI {
319+
if (![_externalIntentURI isEqualToString:externalIntentURI]) {
320+
_externalIntentURI = externalIntentURI;
321+
[self writeObjectToDefaults:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI value:externalIntentURI];
322+
}
323+
}
324+
310325
- (NSString *)universalLinkUrl {
311326
if (!_universalLinkUrl) {
312327
_universalLinkUrl = [self readStringFromDefaults:BRANCH_PREFS_KEY_UNIVERSAL_LINK_URL];

Branch-SDK/Branch-SDK/Branch.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options isReferrable:(BOOL)
386386
- (BOOL)handleDeepLink:(NSURL *)url {
387387
BOOL handled = NO;
388388
if (url) {
389+
//always save the incoming url in the preferenceHelper in the externalIntentURI field
390+
self.preferenceHelper.externalIntentURI = [url absoluteString];
391+
389392
NSString *query = [url fragment];
390393
if (!query) {
391394
query = [url query];
@@ -404,6 +407,7 @@ - (BOOL)handleDeepLink:(NSURL *)url {
404407
}
405408

406409
- (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
410+
//check to see if a browser activity needs to be handled
407411
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
408412
self.preferenceHelper.universalLinkUrl = [userActivity.webpageURL absoluteString];
409413

@@ -425,6 +429,7 @@ - (BOOL)continueUserActivity:(NSUserActivity *)userActivity {
425429
return [[userActivity.webpageURL absoluteString] containsString:@"bnc.lt"];
426430
}
427431

432+
//check to see if a spotlight activity needs to be handled
428433
NSString *spotlightIdentifier = [self.contentDiscoveryManager spotlightIdentifierFromActivity:userActivity];
429434

430435
if (spotlightIdentifier) {

Branch-SDK/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_SCREEN_HEIGHT;
6060
extern NSString * const BRANCH_REQUEST_KEY_DEVICE_NAME;
6161
extern NSString * const BRANCH_REQUEST_KEY_IS_SIMULATOR;
6262
extern NSString * const BRANCH_REQUEST_KEY_LOG;
63+
extern NSString * const BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI;
6364

6465
extern NSString * const BRANCH_REQUEST_ENDPOINT_SET_IDENTITY;
6566
extern NSString * const BRANCH_REQUEST_ENDPOINT_LOGOUT;

Branch-SDK/Branch-SDK/Requests/BranchOpenRequest.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +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-
67+
[self safeSetValue:preferenceHelper.externalIntentURI forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:params];
6868
[serverInterface postRequest:params url:[preferenceHelper getAPIURL:BRANCH_REQUEST_ENDPOINT_OPEN] key:key callback:callback];
6969
}
7070

@@ -124,6 +124,7 @@ - (void)processResponse:(BNCServerResponse *)response error:(NSError *)error {
124124
preferenceHelper.linkClickIdentifier = nil;
125125
preferenceHelper.spotlightIdentifier = nil;
126126
preferenceHelper.universalLinkUrl = nil;
127+
preferenceHelper.externalIntentURI = nil;
127128

128129
if (data[BRANCH_RESPONSE_KEY_BRANCH_IDENTITY]) {
129130
preferenceHelper.identityID = data[BRANCH_RESPONSE_KEY_BRANCH_IDENTITY];

Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,8 @@
998998
CLANG_WARN_INT_CONVERSION = YES;
999999
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
10001000
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
1001-
CODE_SIGN_IDENTITY = "iPhone Developer: Qinwei Gong (B77F7AKCX2)";
1002-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Qinwei Gong (B77F7AKCX2)";
1001+
CODE_SIGN_IDENTITY = "iPhone Developer";
1002+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
10031003
COPY_PHASE_STRIP = NO;
10041004
ENABLE_TESTABILITY = YES;
10051005
GCC_C_LANGUAGE_STANDARD = gnu99;
@@ -1038,7 +1038,8 @@
10381038
CLANG_WARN_INT_CONVERSION = YES;
10391039
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
10401040
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
1041-
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer: Qinwei Gong (B77F7AKCX2)";
1041+
CODE_SIGN_IDENTITY = "iPhone Developer";
1042+
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
10421043
COPY_PHASE_STRIP = YES;
10431044
ENABLE_NS_ASSERTIONS = NO;
10441045
GCC_C_LANGUAGE_STANDARD = gnu99;

0 commit comments

Comments
 (0)