Skip to content

Commit 6bc2857

Browse files
committed
Release 2.2.2
1 parent 4d4846e commit 6bc2857

File tree

9 files changed

+1026
-680
lines changed

9 files changed

+1026
-680
lines changed

Branch-TestBed/Branch-SDK-Tests/BNCReferringURLUtilityTests.m

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,4 +401,116 @@ - (void)verifyOldGbraidDataIsCleared {
401401
XCTAssertNil([BNCPreferenceHelper sharedInstance].referrerGBRAIDInitDate);
402402
}
403403

404+
- (void)testReferringURLWithSccid {
405+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid=12345"];
406+
NSDictionary *expected = @{
407+
@"sccid": @"12345"
408+
};
409+
410+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
411+
[utility parseReferringURL:url];
412+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
413+
414+
XCTAssert([expected isEqualToDictionary:params]);
415+
}
416+
417+
- (void)testReferringURLWithSccidMixedCase {
418+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?ScCiD=12345"];
419+
NSDictionary *expected = @{
420+
@"sccid": @"12345"
421+
};
422+
423+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
424+
[utility parseReferringURL:url];
425+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
426+
427+
XCTAssert([expected isEqualToDictionary:params]);
428+
}
429+
430+
- (void)testReferringURLWithSccidNoValue {
431+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid="];
432+
NSDictionary *expected = @{
433+
@"sccid": @""
434+
};
435+
436+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
437+
[utility parseReferringURL:url];
438+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
439+
440+
XCTAssert([expected isEqualToDictionary:params]);
441+
}
442+
443+
- (void)testReferringURLWithSccidValueCasePreserved {
444+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid=aAbBcC"];
445+
NSDictionary *expected = @{
446+
@"sccid": @"aAbBcC"
447+
};
448+
449+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
450+
[utility parseReferringURL:url];
451+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
452+
453+
XCTAssert([expected isEqualToDictionary:params]);
454+
}
455+
456+
- (void)testReferringURLWithSccidIgnoredParam {
457+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid=12345&other=abcde"];
458+
NSDictionary *expected = @{
459+
@"sccid": @"12345"
460+
};
461+
462+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
463+
[utility parseReferringURL:url];
464+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
465+
466+
XCTAssert([expected isEqualToDictionary:params]);
467+
}
468+
469+
- (void)testReferringURLWithSccidFragment{
470+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid=12345#header"];
471+
NSDictionary *expected = @{
472+
@"sccid": @"12345"
473+
};
474+
475+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
476+
[utility parseReferringURL:url];
477+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
478+
479+
XCTAssert([expected isEqualToDictionary:params]);
480+
}
481+
482+
- (void)testReferringURLWithSccidAsFragment{
483+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?other=abcde#sccid=12345"];
484+
NSDictionary *expected = @{ };
485+
486+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
487+
[utility parseReferringURL:url];
488+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
489+
490+
XCTAssert([expected isEqualToDictionary:params]);
491+
}
492+
493+
- (void)testReferringURLWithSccidOverwritesValue {
494+
NSURL *url = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid=12345"];
495+
NSDictionary *expected = @{
496+
@"sccid": @"12345"
497+
};
498+
499+
NSURL *url2 = [NSURL URLWithString:@"https://bnctestbed.app.link?sccid=abcde"];
500+
NSDictionary *expected2 = @{
501+
@"sccid": @"abcde"
502+
};
503+
504+
BNCReferringURLUtility *utility = [self referringUtilityForTests];
505+
[utility parseReferringURL:url];
506+
NSDictionary *params = [utility referringURLQueryParamsForEndpoint:openEndpoint];
507+
XCTAssert([expected isEqualToDictionary:params]);
508+
509+
[utility parseReferringURL:url2];
510+
NSDictionary *params2 = [utility referringURLQueryParamsForEndpoint:openEndpoint];
511+
512+
XCTAssert([expected2 isEqualToDictionary:params2]);
513+
}
514+
515+
404516
@end

BranchSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "BranchSDK"
3-
s.version = "2.2.1"
3+
s.version = "2.2.2"
44
s.summary = "Create an HTTP URL for any piece of content in your app"
55
s.description = <<-DESC
66
- Want the highest possible conversions on your sharing feature?

BranchSDK.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@
20692069
"@executable_path/Frameworks",
20702070
"@loader_path/Frameworks",
20712071
);
2072-
MARKETING_VERSION = 2.2.1;
2072+
MARKETING_VERSION = 2.2.2;
20732073
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
20742074
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
20752075
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2100,7 +2100,7 @@
21002100
"@executable_path/Frameworks",
21012101
"@loader_path/Frameworks",
21022102
);
2103-
MARKETING_VERSION = 2.2.1;
2103+
MARKETING_VERSION = 2.2.2;
21042104
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
21052105
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
21062106
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2302,7 +2302,7 @@
23022302
"@loader_path/Frameworks",
23032303
);
23042304
MACH_O_TYPE = staticlib;
2305-
MARKETING_VERSION = 2.2.1;
2305+
MARKETING_VERSION = 2.2.2;
23062306
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
23072307
PRODUCT_MODULE_NAME = BranchSDK;
23082308
PRODUCT_NAME = BranchSDK;
@@ -2337,7 +2337,7 @@
23372337
"@loader_path/Frameworks",
23382338
);
23392339
MACH_O_TYPE = staticlib;
2340-
MARKETING_VERSION = 2.2.1;
2340+
MARKETING_VERSION = 2.2.2;
23412341
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
23422342
PRODUCT_MODULE_NAME = BranchSDK;
23432343
PRODUCT_NAME = BranchSDK;
@@ -2369,7 +2369,7 @@
23692369
"@executable_path/Frameworks",
23702370
"@loader_path/Frameworks",
23712371
);
2372-
MARKETING_VERSION = 2.2.1;
2372+
MARKETING_VERSION = 2.2.2;
23732373
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
23742374
PRODUCT_NAME = BranchSDK;
23752375
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -2399,7 +2399,7 @@
23992399
"@executable_path/Frameworks",
24002400
"@loader_path/Frameworks",
24012401
);
2402-
MARKETING_VERSION = 2.2.1;
2402+
MARKETING_VERSION = 2.2.2;
24032403
PRODUCT_BUNDLE_IDENTIFIER = io.branch.BranchSDK;
24042404
PRODUCT_NAME = BranchSDK;
24052405
PROVISIONING_PROFILE_SPECIFIER = "";

BranchSDK/BNCConfig.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
NSString * const BNC_API_BASE_URL = @"https://api2.branch.io";
1212
NSString * const BNC_API_VERSION = @"v1";
1313
NSString * const BNC_LINK_URL = @"https://bnc.lt";
14-
NSString * const BNC_SDK_VERSION = @"2.2.1";
14+
NSString * const BNC_SDK_VERSION = @"2.2.2";
1515
NSString * const BNC_CDN_URL = @"https://cdn.branch.io";

BranchSDK/BNCReferringURLUtility.m

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "BranchConstants.h"
1212
#import "BNCUrlQueryParameter.h"
1313
#import "BNCLog.h"
14+
#import <UIKit/UIKit.h>
1415

1516
@interface BNCReferringURLUtility()
1617
@property (strong, readwrite, nonatomic) NSMutableDictionary<NSString *, BNCUrlQueryParameter *> *urlQueryParameters;
@@ -25,10 +26,25 @@ - (instancetype)init {
2526
self.preferenceHelper = [BNCPreferenceHelper sharedInstance];
2627
self.urlQueryParameters = [self deserializeFromJson:self.preferenceHelper.referringURLQueryParameters];
2728
[self checkForAndMigrateOldGbraid];
29+
30+
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
31+
[notificationCenter addObserver:self
32+
selector:@selector(clearSccid)
33+
name:UIApplicationDidEnterBackgroundNotification
34+
object:nil];
35+
[notificationCenter addObserver:self
36+
selector:@selector(clearSccid)
37+
name:UIApplicationWillTerminateNotification
38+
object:nil];
2839
}
2940
return self;
3041
}
3142

43+
- (void)dealloc {
44+
[[NSNotificationCenter defaultCenter] removeObserver:self];
45+
}
46+
47+
3248
- (void)parseReferringURL:(NSURL *)url {
3349
NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
3450
for (NSURLQueryItem *item in components.queryItems) {
@@ -107,6 +123,7 @@ - (NSDictionary *)referringURLQueryParamsForEndpoint:(NSString *)endpoint {
107123
params[BRANCH_REQUEST_KEY_META_CAMPAIGN_IDS] = [self metaCampaignIDsForEndpoint:endpoint];
108124
params[BRANCH_REQUEST_KEY_GCLID] = [self gclidValueForEndpoint:endpoint];
109125
[params addEntriesFromDictionary:[self gbraidValuesForEndpoint:endpoint]];
126+
params[BRANCH_REQUEST_KEY_SCCID] = [self sccidValueForEndpoint:endpoint];
110127

111128
return params;
112129
}
@@ -153,8 +170,15 @@ - (NSDictionary *)gbraidValuesForEndpoint:(NSString *)endpoint {
153170
return returnedParams;
154171
}
155172

173+
- (NSString *)sccidValueForEndpoint:(NSString *)endpoint {
174+
if (([endpoint containsString:@"/v2/event"]) || ([endpoint containsString:@"/v1/open"]) || ([endpoint containsString:@"/v1/install"]) ) {
175+
return self.urlQueryParameters[BRANCH_REQUEST_KEY_SCCID].value;
176+
}
177+
return nil;
178+
}
179+
156180
- (BOOL)isSupportedQueryParameter:(NSString *)param {
157-
NSArray *validURLQueryParameters = @[BRANCH_REQUEST_KEY_REFERRER_GBRAID, BRANCH_REQUEST_KEY_GCLID];
181+
NSArray *validURLQueryParameters = @[BRANCH_REQUEST_KEY_REFERRER_GBRAID, BRANCH_REQUEST_KEY_GCLID, BRANCH_REQUEST_KEY_SCCID];
158182
return [self isSupportedQueryParameter:param validParams:validURLQueryParameters];
159183
}
160184

@@ -266,4 +290,10 @@ - (void)checkForAndMigrateOldGbraid {
266290
}
267291
}
268292

293+
- (void)clearSccid {
294+
[self.urlQueryParameters removeObjectForKey:BRANCH_REQUEST_KEY_SCCID];
295+
self.preferenceHelper.referringURLQueryParameters = [self serializeToJson:self.urlQueryParameters];
296+
}
297+
298+
269299
@end

BranchSDK/BranchConstants.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ extern NSString * const BRANCH_URL_QUERY_PARAMETERS_VALUE_KEY;
8989
extern NSString * const BRANCH_URL_QUERY_PARAMETERS_TIMESTAMP_KEY;
9090
extern NSString * const BRANCH_URL_QUERY_PARAMETERS_IS_DEEPLINK_KEY;
9191
extern NSString * const BRANCH_URL_QUERY_PARAMETERS_VALIDITY_WINDOW_KEY;
92+
extern NSString * const BRANCH_REQUEST_KEY_SCCID;
9293

9394
extern NSString * const BRANCH_REQUEST_ENDPOINT_SET_IDENTITY;
9495
extern NSString * const BRANCH_REQUEST_ENDPOINT_APP_LINK_SETTINGS;

BranchSDK/BranchConstants.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
NSString * const BRANCH_URL_QUERY_PARAMETERS_TIMESTAMP_KEY = @"timestamp";
8585
NSString * const BRANCH_URL_QUERY_PARAMETERS_IS_DEEPLINK_KEY = @"isDeepLink";
8686
NSString * const BRANCH_URL_QUERY_PARAMETERS_VALIDITY_WINDOW_KEY = @"validityWindow";
87+
NSString * const BRANCH_REQUEST_KEY_SCCID = @"sccid";
8788

8889
NSString * const BRANCH_REQUEST_ENDPOINT_SET_IDENTITY = @"profile";
8990
NSString * const BRANCH_REQUEST_ENDPOINT_APP_LINK_SETTINGS = @"app-link-settings";

0 commit comments

Comments
 (0)