Skip to content

Commit

Permalink
[SDK-2474] Fix for sending URI scheme as universal_link_url (#1420)
Browse files Browse the repository at this point in the history
* Fix for some URI scheme bugs

* Remove unrelated code

* Added if to set the external intent URI
  • Loading branch information
nsingh-branch authored Aug 20, 2024
1 parent b812991 commit 60fca2a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Sources/BranchSDK/BNCRequestFactory.m
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ - (NSDictionary *)dataForInstallWithURLString:(NSString *)urlString {
[self addAppleReceiptSourceToJSON:json];
[self addTimestampsToJSON:json];

// Check if the urlString is a valid URL to ensure it's a universal link, not the external intent uri
if (urlString) {
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
NSURL *url = [NSURL URLWithString:urlString];
if (url && ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])) {
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
} else {
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json];
}
}

[self addAppleAttributionTokenToJSON:json];
Expand Down Expand Up @@ -147,8 +153,15 @@ - (NSDictionary *)dataForOpenWithURLString:(NSString *)urlString {
[self addAppleReceiptSourceToJSON:json];
[self addTimestampsToJSON:json];


// Check if the urlString is a valid URL to ensure it's a universal link, not the external intent uri
if (urlString) {
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
NSURL *url = [NSURL URLWithString:urlString];
if (url && ([url.scheme isEqualToString:@"http"] || [url.scheme isEqualToString:@"https"])) {
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_UNIVERSAL_LINK_URL onDict:json];
} else {
[self safeSetValue:urlString forKey:BRANCH_REQUEST_KEY_EXTERNAL_INTENT_URI onDict:json];
}
}

// Usually sent with install, but retry on open if it didn't get sent
Expand Down

0 comments on commit 60fca2a

Please sign in to comment.