Skip to content

Commit 56c92ff

Browse files
Looped through each of the URI schemes so that Branch doesn't have to be the first URI scheme in the list for the integration validator to pass
Looped through each of the URI schemes so that Branch doesn't have to be the first URI scheme in the list for the integration validator to pass
1 parent 8e353a9 commit 56c92ff

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

BranchSDK/BNCSystemObserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
+ (NSString *)appleAttributionToken;
3434
+ (NSString *)environment;
3535
+ (BOOL)isAppClip;
36+
+ (BOOL)compareUriSchemes:(NSString *) serverUriScheme;
3637

3738
@end

BranchSDK/BNCSystemObserver.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,23 @@ + (NSString *)defaultURIScheme {
142142
return nil;
143143
}
144144

145+
+ (BOOL)compareUriSchemes : (NSString *) serverUriScheme {
146+
NSArray *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
147+
148+
for (NSDictionary *urlType in urlTypes) {
149+
150+
NSArray *urlSchemes = [urlType objectForKey:@"CFBundleURLSchemes"];
151+
for (NSString *uriScheme in urlSchemes) {
152+
NSString * serverUriSchemeWithoutSuffix = [serverUriScheme substringToIndex:[serverUriScheme length] - 3];
153+
if ([uriScheme isEqualToString:serverUriSchemeWithoutSuffix]) {
154+
return true; }
155+
}
156+
// If no Uri schemes match the one set on the dashboard
157+
return false;
158+
}
159+
return false;
160+
}
161+
145162
+ (NSString *)bundleIdentifier {
146163
return [[NSBundle mainBundle] bundleIdentifier];
147164
}

BranchSDK/Branch+Validator.m

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,13 @@ - (void) validateIntegrationWithServerResponse:(BNCServerResponse*)response {
6969

7070
NSLog(@"------ Checking for URI scheme correctness ------");
7171
NSString *clientUriScheme = [NSString stringWithFormat:@"%@%@", [BNCSystemObserver defaultURIScheme], @"://"];
72-
NSString *uriScheme = [serverUriScheme isEqualToString:clientUriScheme] ? passString : errorString;
73-
NSString *uriSchemeMessage =
74-
[NSString stringWithFormat:@"%@: Dashboard Link Settings page '%@' compared to client side '%@'",
75-
uriScheme, serverUriScheme, clientUriScheme];
76-
NSLog(@"%@",uriSchemeMessage);
72+
NSString *uriScheme = [BNCSystemObserver compareUriSchemes:serverUriScheme] ? passString : errorString;
7773
NSLog(@"-------------------------------------------------");
7874

7975
NSLog(@"-- Checking for bundle identifier correctness ---");
8076
NSString *clientBundleIdentifier = [[NSBundle mainBundle] bundleIdentifier] ?: @"";
81-
NSString *bundleIdentifier = [serverBundleID isEqualToString:clientBundleIdentifier] ? passString : errorString;
77+
bool doUriSchemesMatch = [serverBundleID isEqualToString:clientBundleIdentifier];
78+
NSString *bundleIdentifier = doUriSchemesMatch ? passString : errorString;
8279
NSString *bundleIdentifierMessage =
8380
[NSString stringWithFormat:@"%@: Dashboard Link Settings page '%@' compared to client side '%@'",
8481
bundleIdentifier, serverBundleID, clientBundleIdentifier];
@@ -113,7 +110,7 @@ - (void) validateIntegrationWithServerResponse:(BNCServerResponse*)response {
113110

114111
// Build an alert string:
115112
NSString *alertString = @"\n";
116-
if (serverUriScheme.length && [serverUriScheme isEqualToString:clientUriScheme]) {
113+
if (serverUriScheme.length && doUriSchemesMatch) {
117114
alertString = [alertString stringByAppendingFormat:@"%@URI Scheme matches:\n\t'%@'\n",
118115
kPassMark, serverUriScheme];
119116
} else {

0 commit comments

Comments
 (0)