From f7746380d1400937a9ace4fcf30c9be75a807c16 Mon Sep 17 00:00:00 2001 From: tuan nguyen Date: Mon, 12 May 2025 19:01:39 +0700 Subject: [PATCH] Fix: Handle intent:// deep links in checkout --- .../checkoutsheetkit/CheckoutEventProcessor.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/src/main/java/com/shopify/checkoutsheetkit/CheckoutEventProcessor.kt b/lib/src/main/java/com/shopify/checkoutsheetkit/CheckoutEventProcessor.kt index c7039e4a..a73e43ac 100644 --- a/lib/src/main/java/com/shopify/checkoutsheetkit/CheckoutEventProcessor.kt +++ b/lib/src/main/java/com/shopify/checkoutsheetkit/CheckoutEventProcessor.kt @@ -206,11 +206,19 @@ public abstract class DefaultCheckoutEventProcessor @JvmOverloads constructor( @SuppressLint("QueryPermissionsNeeded") private fun Context.tryLaunchDeepLink(uri: Uri) { log.d(LOG_TAG, "Attempting to launch deep link for uri $uri.") - val intent = Intent(Intent.ACTION_VIEW) - intent.data = uri - if (context.packageManager.queryIntentActivities(intent, 0).isNotEmpty()) { + + val intent = try { + // ⚠️ Parse intent://...#Intent;...;end; + Intent.parseUri(uri.toString(), Intent.URI_INTENT_SCHEME) + } catch (e: Exception) { + log.e(TAG, "Failed to parse deep link intent: $uri", e) + return + } + + try { startActivity(intent) - } else { + } catch (e: Exception) { + log.e(TAG, "Failed to start activity for deep link: $uri", e) log.w(TAG, "Unrecognized scheme for link clicked in checkout '$uri'") } }