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