Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc Bug Fixes : SDK-2530, SDK-2532 #1465

Open
wants to merge 3 commits into
base: SDK-2519-OpenRequest
Choose a base branch
from
Open
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
43 changes: 43 additions & 0 deletions Branch-TestBed/Branch-SDK-Tests/BNCServerInterfaceTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// BNCServerInterfaceTests.m
// Branch-SDK-Tests
//
// Created by Nidhi Dixit on 1/7/25.
// Copyright © 2025 Branch, Inc. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "Branch/BNCServerInterface.h"

@interface BNCServerInterface()
- (BOOL)isLinkingRelatedRequest:(NSString *)endpoint postParams:(NSDictionary *)post;
@end

@interface BNCServerInterfaceTests : XCTestCase
@end

@implementation BNCServerInterfaceTests

- (void)testIsLinkingRelatedRequest {

BNCServerInterface *serverInterface = [[BNCServerInterface alloc] init];

// install
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/install" postParams:nil]);

// open
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:nil]);
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{}]);
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"spotlight_identifier":@"io.branch.link.v1.url.testbed.app.link/1234"}]);
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"link_identifier": @"1305991233204308323"}]);
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"universal_link_url":@"branchtest://open?_branch_referrer=H4sIAAAAAAAAA8soKSkottLXT8pLLkktLklKTd"}]);
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v1/open" postParams:@{@"uri_scheme" : @"branchtest"}]);

// v2/event
XCTAssertFalse([serverInterface isLinkingRelatedRequest:@"/v2/event" postParams:@{@"spotlight_identifier":@"io.branch.link.v1.url.testbed.app.link/1234"}]);

// v1/url
XCTAssertTrue([serverInterface isLinkingRelatedRequest:@"/v1/url" postParams:nil]);

}
@end
4 changes: 4 additions & 0 deletions Branch-TestBed/Branch-TestBed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
C17DAF7B2AC20C2000B16B1A /* BranchClassTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C17DAF7A2AC20C2000B16B1A /* BranchClassTests.m */; };
C1CC888229BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */; };
E72489D228E40D0200DCD8FD /* PasteControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E72489D128E40D0200DCD8FD /* PasteControlViewController.m */; };
E74B54402D2DB0660049A89D /* BNCServerInterfaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E74B543F2D2DB0660049A89D /* BNCServerInterfaceTests.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, ); }; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -538,6 +539,7 @@
C1CC888129BAAFC000BDD2B5 /* BNCReferringURLUtilityTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCReferringURLUtilityTests.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>"; };
E74B543F2D2DB0660049A89D /* BNCServerInterfaceTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCServerInterfaceTests.m; sourceTree = "<group>"; };
E7A728BC2AA9A112009343B7 /* BNCAPIServerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BNCAPIServerTest.m; sourceTree = "<group>"; };
F1D4F9AC1F323F01002D13FF /* Branch-TestBed-UITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Branch-TestBed-UITests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -648,6 +650,7 @@
5F8650192B76DA3200364BDE /* NSMutableDictionaryBranchTests.m */,
4D16839E2098C901008819E3 /* NSStringBranchTests.m */,
5F6D86D82BB5E9650068B536 /* BNCClassSerializationTests.m */,
E74B543F2D2DB0660049A89D /* BNCServerInterfaceTests.m */,
);
path = "Branch-SDK-Tests";
sourceTree = "<group>";
Expand Down Expand Up @@ -1360,6 +1363,7 @@
files = (
4D1683B82098C902008819E3 /* BNCEncodingUtilsTests.m in Sources */,
5F909B5E23314CE900A774D2 /* BNCJSONUtilityTests.m in Sources */,
E74B54402D2DB0660049A89D /* BNCServerInterfaceTests.m in Sources */,
5F909B722332BEF600A774D2 /* BranchLastAttributedTouchDataTests.m in Sources */,
5FC20E732A93D85F00D9E1C8 /* BNCRequestFactoryTests.m in Sources */,
5FA9112F29BC662000F3D35C /* BNCNetworkInterfaceTests.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/BranchSDK/BNCServerInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN

- (BOOL)isLinkingRelatedRequest:(NSString *)endpoint postParams:(NSDictionary *)post {

BOOL hasIdentifier = (post[BRANCH_REQUEST_KEY_LINK_IDENTIFIER] != nil ) || (post[BRANCH_REQUEST_KEY_LINK_IDENTIFIER] != nil) || (post[BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL] != nil);
gdeluna-branch marked this conversation as resolved.
Show resolved Hide resolved
BOOL hasIdentifier = (post[BRANCH_REQUEST_KEY_LINK_IDENTIFIER] != nil ) || (post[BRANCH_REQUEST_KEY_SPOTLIGHT_IDENTIFIER] != nil) || (post[BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL] != nil);

// Allow install to resolve a link.
if ([endpoint containsString:@"/v1/install"]) {
Expand Down
8 changes: 4 additions & 4 deletions Sources/BranchSDK/Branch.m
Original file line number Diff line number Diff line change
Expand Up @@ -704,18 +704,18 @@ - (void)initSessionWithLaunchOptions:(NSDictionary *)options
self.shouldAutomaticallyDeepLink = automaticallyDisplayController;

// Check for Branch link in a push payload
BranchOpenRequestLinkParams *params = [[BranchOpenRequestLinkParams alloc] init];
BOOL appLaunchViaPushNotification = NO;
#if !TARGET_OS_TV
if ([options objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
id branchUrlFromPush = [options objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey][BRANCH_PUSH_NOTIFICATION_PAYLOAD_KEY];
if ([branchUrlFromPush isKindOfClass:[NSString class]]) {
params.referringURL = (NSString *)branchUrlFromPush;
appLaunchViaPushNotification = YES;
}
}
#endif

if(params.referringURL || [[options objectForKey:@"BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY"] isEqualToNumber:@1] || (![options.allKeys containsObject:UIApplicationLaunchOptionsURLKey] && ![options.allKeys containsObject:UIApplicationLaunchOptionsUserActivityDictionaryKey]) ) {
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlParams:params reset:NO];
if( [[options objectForKey:@"BRANCH_DEFER_INIT_FOR_PLUGIN_RUNTIME_KEY"] isEqualToNumber:@1] || (![options.allKeys containsObject:UIApplicationLaunchOptionsURLKey] && ![options.allKeys containsObject:UIApplicationLaunchOptionsUserActivityDictionaryKey] && !appLaunchViaPushNotification)) {
[self initUserSessionAndCallCallback:YES sceneIdentifier:nil urlParams:nil reset:NO];
}
}

Expand Down
Loading