Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BNCSystemObserverTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#import <XCTest/XCTest.h>
#import "BNCSystemObserver.h"

@interface BNCSystemObserver ()
+ (BOOL)compareUriSchemes:(NSString *)serverUriScheme With:(NSArray *)urlTypes;
@end

@interface BNCSystemObserverTests : XCTestCase

@end
Expand Down Expand Up @@ -100,4 +104,35 @@ - (void)testIsAppClip {
XCTAssert(![BNCSystemObserver isAppClip]);
}

- (void)testCompareURIScemes {

NSString *serverUriScheme = @"bnctest://";
NSArray *urlTypes = @[@{@"CFBundleURLSchemes" : @[@""]}, @{@"CFBundleURLSchemes" : @[@"bnctest", @"xyzs"]}];

XCTAssertTrue([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:nil]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:nil With:nil]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:nil With:urlTypes]);

serverUriScheme = @":/";
XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

serverUriScheme = @"bnctest";
XCTAssertTrue([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

serverUriScheme = @"bnctest://";
urlTypes = @[ @{@"CFBundleURLSchemes" : @[@"bnctestX", @"xyzs"]}];
XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

serverUriScheme = @"://";
XCTAssertFalse([BNCSystemObserver compareUriSchemes:serverUriScheme With:urlTypes]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:@"" With:urlTypes]);

XCTAssertFalse([BNCSystemObserver compareUriSchemes:@"" With:@[@{}]]);
}

@end
9 changes: 8 additions & 1 deletion Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
5F644C492B7AA811000DCD78 /* BNCEventUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F644BB82B7AA811000DCD78 /* BNCEventUtils.m */; };
5F67F48E228F535500067429 /* BNCEncodingUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F67F48D228F535500067429 /* BNCEncodingUtilsTests.m */; };
5F6D86D92BB5E9650068B536 /* BNCClassSerializationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F6D86D82BB5E9650068B536 /* BNCClassSerializationTests.m */; };
5F83B9ED2433BAAA0054A022 /* BNCServerInterface.Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D16837E2098C901008819E3 /* BNCServerInterface.Test.m */; };
5F86501A2B76DA3200364BDE /* NSMutableDictionaryBranchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F8650192B76DA3200364BDE /* NSMutableDictionaryBranchTests.m */; };
5F892EC5236116CD0023AEC1 /* NSErrorBranchTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 5F892EC4236116CC0023AEC1 /* NSErrorBranchTests.m */; };
5F8B7B4021B5F5CD009CE0A6 /* libBranch.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 466B58381B17773000A69EDE /* libBranch.a */; };
Expand Down Expand Up @@ -235,6 +234,8 @@
C1614D56285BC8A00098946B /* LinkPresentation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C1614D55285BC8A00098946B /* LinkPresentation.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
C17DAF7B2AC20C2000B16B1A /* BranchClassTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C17DAF7A2AC20C2000B16B1A /* BranchClassTests.m */; };
C1CC888229BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */; };
E51F642A2CF46899000858D2 /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E51F64292CF46899000858D2 /* BranchFileLogger.h */; };
E56394312CC7AC9F00E18E65 /* BranchFileLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = E563942F2CC7AC9500E18E65 /* BranchFileLogger.m */; };
E72489D228E40D0200DCD8FD /* PasteControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E72489D128E40D0200DCD8FD /* PasteControlViewController.m */; };
E7A728BD2AA9A112009343B7 /* BNCAPIServerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */; };
F1CF14111F4CC79F00BB2694 /* CoreSpotlight.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 67F270881BA9FCFF002546A7 /* CoreSpotlight.framework */; settings = {ATTRIBUTES = (Required, ); }; };
Expand Down Expand Up @@ -539,6 +540,8 @@
C1614D55285BC8A00098946B /* LinkPresentation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LinkPresentation.framework; path = System/Library/Frameworks/LinkPresentation.framework; sourceTree = SDKROOT; };
C17DAF7A2AC20C2000B16B1A /* BranchClassTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BranchClassTests.m; sourceTree = "<group>"; };
C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCReferringURLUtilityTests.m; sourceTree = "<group>"; };
E51F64292CF46899000858D2 /* BranchFileLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchFileLogger.h; sourceTree = "<group>"; };
E563942F2CC7AC9500E18E65 /* BranchFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchFileLogger.m; sourceTree = "<group>"; };
E72489D028E40D0200DCD8FD /* PasteControlViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteControlViewController.h; sourceTree = "<group>"; };
E72489D128E40D0200DCD8FD /* PasteControlViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PasteControlViewController.m; sourceTree = "<group>"; };
E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCAPIServerTest.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -676,6 +679,7 @@
5F644B252B7AA810000DCD78 /* BranchSDK */ = {
isa = PBXGroup;
children = (
E563942F2CC7AC9500E18E65 /* BranchFileLogger.m */,
5F644BB02B7AA811000DCD78 /* BNCAppGroupsData.m */,
5F644BA82B7AA811000DCD78 /* BNCAppleReceipt.m */,
5F644B2B2B7AA810000DCD78 /* BNCApplication.m */,
Expand Down Expand Up @@ -834,6 +838,7 @@
5F644B862B7AA811000DCD78 /* NSError+Branch.h */,
5F644B822B7AA811000DCD78 /* NSMutableDictionary+Branch.h */,
5F644B8B2B7AA811000DCD78 /* NSString+Branch.h */,
E51F64292CF46899000858D2 /* BranchFileLogger.h */,
5F644B752B7AA810000DCD78 /* UIViewController+Branch.h */,
);
path = Private;
Expand Down Expand Up @@ -958,6 +963,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
E51F642A2CF46899000858D2 /* BranchFileLogger.h in Headers */,
5F644BE52B7AA811000DCD78 /* BNCLinkData.h in Headers */,
5F644BE62B7AA811000DCD78 /* BranchDelegate.h in Headers */,
5F644BE72B7AA811000DCD78 /* BranchQRCode.h in Headers */,
Expand Down Expand Up @@ -1317,6 +1323,7 @@
5F644BD72B7AA811000DCD78 /* BNCNetworkService.m in Sources */,
5F644C402B7AA811000DCD78 /* UIViewController+Branch.m in Sources */,
5F644BC12B7AA811000DCD78 /* BNCServerRequestQueue.m in Sources */,
E56394312CC7AC9F00E18E65 /* BranchFileLogger.m in Sources */,
5F644C452B7AA811000DCD78 /* BranchOpenRequest.m in Sources */,
5F644C312B7AA811000DCD78 /* BNCLinkData.m in Sources */,
5F644BD22B7AA811000DCD78 /* BranchContentDiscoveryManifest.m in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions BranchSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,11 @@
5FCDD5B22B7AC89100EAF29F /* BranchSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF2AFDF28E7C22100393216 /* BranchSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
5FCDD5B32B7AC89200EAF29F /* BranchSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF2AFDF28E7C22100393216 /* BranchSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
5FCDD5B42B7AC89200EAF29F /* BranchSDK.h in Headers */ = {isa = PBXBuildFile; fileRef = 5FF2AFDF28E7C22100393216 /* BranchSDK.h */; settings = {ATTRIBUTES = (Public, ); }; };
E52E5B062CC79E4E00F553EE /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */; settings = {ATTRIBUTES = (Public, ); }; };
E52E5B072CC79E4E00F553EE /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */; };
E52E5B0A2CC79E5C00F553EE /* BranchFileLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */; };
E52E5B0B2CC79E5C00F553EE /* BranchFileLogger.m in Sources */ = {isa = PBXBuildFile; fileRef = E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */; };
E563942E2CC7A8E600E18E65 /* BranchFileLogger.h in Headers */ = {isa = PBXBuildFile; fileRef = E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -698,6 +703,8 @@
5FF2AFDC28E7BF8A00393216 /* build_xcframework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = build_xcframework.sh; sourceTree = "<group>"; };
5FF2AFDE28E7C22100393216 /* module.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = "<group>"; };
5FF2AFDF28E7C22100393216 /* BranchSDK.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BranchSDK.h; sourceTree = "<group>"; };
E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BranchFileLogger.h; sourceTree = "<group>"; };
E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BranchFileLogger.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -811,6 +818,7 @@
5FCDD36B2B7AC6A100EAF29F /* BranchSDK */ = {
isa = PBXGroup;
children = (
E52E5B092CC79E5C00F553EE /* BranchFileLogger.m */,
5FCDD3F62B7AC6A100EAF29F /* BNCAppGroupsData.m */,
5FCDD3EE2B7AC6A100EAF29F /* BNCAppleReceipt.m */,
5FCDD3712B7AC6A100EAF29F /* BNCApplication.m */,
Expand Down Expand Up @@ -969,6 +977,7 @@
5FCDD3CC2B7AC6A100EAF29F /* NSError+Branch.h */,
5FCDD3C82B7AC6A100EAF29F /* NSMutableDictionary+Branch.h */,
5FCDD3D12B7AC6A100EAF29F /* NSString+Branch.h */,
E52E5B052CC79E4E00F553EE /* BranchFileLogger.h */,
5FCDD3BB2B7AC6A100EAF29F /* UIViewController+Branch.h */,
);
path = Private;
Expand Down Expand Up @@ -1029,6 +1038,7 @@
5FCDD4A12B7AC6A200EAF29F /* BNCServerResponse.h in Headers */,
5FCDD4C22B7AC6A200EAF29F /* BranchDeepLinkingController.h in Headers */,
5FCDD4B92B7AC6A200EAF29F /* BranchPasteControl.h in Headers */,
E52E5B062CC79E4E00F553EE /* BranchFileLogger.h in Headers */,
5FCDD5072B7AC6A300EAF29F /* BNCUrlQueryParameter.h in Headers */,
5FCDD5462B7AC6A300EAF29F /* BNCConfig.h in Headers */,
5FCDD4E62B7AC6A200EAF29F /* UIViewController+Branch.h in Headers */,
Expand Down Expand Up @@ -1110,6 +1120,7 @@
5FCDD4C32B7AC6A200EAF29F /* BranchDeepLinkingController.h in Headers */,
5FCDD4BA2B7AC6A200EAF29F /* BranchPasteControl.h in Headers */,
5FCDD49F2B7AC6A200EAF29F /* Branch.h in Headers */,
E52E5B072CC79E4E00F553EE /* BranchFileLogger.h in Headers */,
5FCDD5082B7AC6A300EAF29F /* BNCUrlQueryParameter.h in Headers */,
5FCDD5472B7AC6A300EAF29F /* BNCConfig.h in Headers */,
5F5FDA1B2B7DE31E00F14A43 /* BranchLogger.h in Headers */,
Expand Down Expand Up @@ -1190,6 +1201,7 @@
5FCDD4A02B7AC6A200EAF29F /* Branch.h in Headers */,
5FCDD5092B7AC6A300EAF29F /* BNCUrlQueryParameter.h in Headers */,
5FCDD5482B7AC6A300EAF29F /* BNCConfig.h in Headers */,
E563942E2CC7A8E600E18E65 /* BranchFileLogger.h in Headers */,
5FCDD4E82B7AC6A200EAF29F /* UIViewController+Branch.h in Headers */,
5FCDD54B2B7AC6A300EAF29F /* BranchConstants.h in Headers */,
5F5FDA1C2B7DE31E00F14A43 /* BranchLogger.h in Headers */,
Expand Down Expand Up @@ -1608,6 +1620,7 @@
5FCDD4592B7AC6A100EAF29F /* BNCNetworkService.m in Sources */,
5FCDD5942B7AC6A400EAF29F /* UIViewController+Branch.m in Sources */,
5FCDD4172B7AC6A100EAF29F /* BNCServerRequestQueue.m in Sources */,
E52E5B0A2CC79E5C00F553EE /* BranchFileLogger.m in Sources */,
5FCDD5A32B7AC6A400EAF29F /* BranchOpenRequest.m in Sources */,
5FCDD5672B7AC6A300EAF29F /* BNCLinkData.m in Sources */,
5FCDD44A2B7AC6A100EAF29F /* BranchContentDiscoveryManifest.m in Sources */,
Expand Down Expand Up @@ -1712,6 +1725,7 @@
5FCDD45A2B7AC6A100EAF29F /* BNCNetworkService.m in Sources */,
5FCDD5952B7AC6A400EAF29F /* UIViewController+Branch.m in Sources */,
5FCDD4182B7AC6A100EAF29F /* BNCServerRequestQueue.m in Sources */,
E52E5B0B2CC79E5C00F553EE /* BranchFileLogger.m in Sources */,
5FCDD5A42B7AC6A400EAF29F /* BranchOpenRequest.m in Sources */,
5FCDD5682B7AC6A400EAF29F /* BNCLinkData.m in Sources */,
5FCDD44B2B7AC6A100EAF29F /* BranchContentDiscoveryManifest.m in Sources */,
Expand Down
28 changes: 24 additions & 4 deletions Sources/BranchSDK/BNCSystemObserver.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,37 @@ + (NSString *)defaultURIScheme {

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

+ (BOOL)compareUriSchemes:(NSString *)serverUriScheme With:(NSArray *)urlTypes {
NSString * serverUriSchemeWithoutSuffix ;

if ([serverUriScheme hasSuffix:@"://"]) {
serverUriSchemeWithoutSuffix = [serverUriScheme substringToIndex:[serverUriScheme length] - 3];
} else {
serverUriSchemeWithoutSuffix = serverUriScheme;
}

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; }
return true;
}
}
}
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharath-branch At line no. 162, if code returns from here, it will not check second and more urlType in array urlTypes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

}

+ (BOOL)compareLinkDomain:(NSString *)serverLinkDomain {
NSArray *linkDomains = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"branch_universal_link_domains"];

for (NSString *domain in linkDomains) {
if ([domain isEqualToString:serverLinkDomain]) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sharath-branch linkdomains strings can have prefix applinks: also. ( Suggested format is our docs is - applinks:subdomain.app.link https://help.branch.io/developers-hub/docs/ios-basic-integration#3-configure-associated-domains ) . So this check will fail if user adds applinks: to domain in info.plist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checking only the info.plist actually and not the associated domains. We recommend adding the prefix applinks: only to associated domains. The recommendation is to add the domains directly to the info.plist without any prefix (https://help.branch.io/developers-hub/docs/ios-basic-integration#4-configure-infoplist).

return true;
}
// If no Uri schemes match the one set on the dashboard
return false;
}
return false;
}
Expand Down
Loading
Loading