Skip to content

Commit

Permalink
Looped through each of the URI schemes so that Branch doesn't have to…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
rob-gioia-branch committed Oct 23, 2023
1 parent 8e353a9 commit 56c92ff
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions BranchSDK/BNCSystemObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
+ (NSString *)appleAttributionToken;
+ (NSString *)environment;
+ (BOOL)isAppClip;
+ (BOOL)compareUriSchemes:(NSString *) serverUriScheme;

@end
17 changes: 17 additions & 0 deletions BranchSDK/BNCSystemObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ + (NSString *)defaultURIScheme {
return nil;
}

+ (BOOL)compareUriSchemes : (NSString *) serverUriScheme {
NSArray *urlTypes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];

for (NSDictionary *urlType in urlTypes) {

NSArray *urlSchemes = [urlType objectForKey:@"CFBundleURLSchemes"];
for (NSString *uriScheme in urlSchemes) {
NSString * serverUriSchemeWithoutSuffix = [serverUriScheme substringToIndex:[serverUriScheme length] - 3];
if ([uriScheme isEqualToString:serverUriSchemeWithoutSuffix]) {
return true; }
}
// If no Uri schemes match the one set on the dashboard
return false;
}
return false;
}

+ (NSString *)bundleIdentifier {
return [[NSBundle mainBundle] bundleIdentifier];
}
Expand Down
11 changes: 4 additions & 7 deletions BranchSDK/Branch+Validator.m
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@ - (void) validateIntegrationWithServerResponse:(BNCServerResponse*)response {

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

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

// Build an alert string:
NSString *alertString = @"\n";
if (serverUriScheme.length && [serverUriScheme isEqualToString:clientUriScheme]) {
if (serverUriScheme.length && doUriSchemesMatch) {
alertString = [alertString stringByAppendingFormat:@"%@URI Scheme matches:\n\t'%@'\n",
kPassMark, serverUriScheme];
} else {
Expand Down

0 comments on commit 56c92ff

Please sign in to comment.