From 60fca2ab36875f0b31cc749dac098b29ea7c4d67 Mon Sep 17 00:00:00 2001 From: Nipun Singh <88689850+nsingh-branch@users.noreply.github.com> Date: Tue, 20 Aug 2024 13:28:50 -0700 Subject: [PATCH] [SDK-2474] Fix for sending URI scheme as universal_link_url (#1420) * Fix for some URI scheme bugs * Remove unrelated code * Added if to set the external intent URI --- Sources/BranchSDK/BNCRequestFactory.m | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Sources/BranchSDK/BNCRequestFactory.m b/Sources/BranchSDK/BNCRequestFactory.m index 570659964..a7d79b23d 100644 --- a/Sources/BranchSDK/BNCRequestFactory.m +++ b/Sources/BranchSDK/BNCRequestFactory.m @@ -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]; @@ -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