From b51421c33ddedeb9505e71ed128b2e8cd600b4e8 Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Thu, 14 May 2026 10:16:35 +0100 Subject: [PATCH 1/2] Make preloading internal until supported --- .../Sources/App/CartManager.swift | 8 ++++---- .../Sources/Scenes/Cart/CartView.swift | 6 +++--- .../Sources/Scenes/Cart/CartViewController.swift | 12 ++++++------ .../ShopifyCheckoutKit/ShopifyCheckoutKit.swift | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/App/CartManager.swift b/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/App/CartManager.swift index de959554..1af9ee47 100644 --- a/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/App/CartManager.swift +++ b/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/App/CartManager.swift @@ -53,10 +53,10 @@ class CartManager: ObservableObject { init() {} public func preloadCheckout() { - if let url = cart?.checkoutURL, isDirty { - ShopifyCheckoutKit.preload(checkout: url) - markCartAsReady() - } + // if let url = cart?.checkoutURL, isDirty { + // ShopifyCheckoutKit.preload(checkout: url) + // markCartAsReady() + // } } func markCartAsReady() { diff --git a/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartView.swift b/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartView.swift index ecb48075..92a92e92 100644 --- a/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartView.swift +++ b/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartView.swift @@ -275,9 +275,9 @@ struct CartLines: View { CartManager.shared.cart = cart updating = nil - if let checkoutUrl = cart.checkoutURL { - ShopifyCheckoutKit.preload(checkout: checkoutUrl) - } + // if let checkoutUrl = cart.checkoutURL { + // ShopifyCheckoutKit.preload(checkout: checkoutUrl) + // } } }, label: { diff --git a/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartViewController.swift b/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartViewController.swift index d4a1e012..4c44c8d1 100644 --- a/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartViewController.swift +++ b/platforms/swift/Samples/MobileBuyIntegration/MobileBuyIntegration/Sources/Scenes/Cart/CartViewController.swift @@ -339,9 +339,9 @@ class CartViewController: UIViewController, UITableViewDelegate, UITableViewData tableView.reloadData() - if let url = CartManager.shared.cart?.checkoutURL { - ShopifyCheckoutKit.preload(checkout: url) - } + // if let url = CartManager.shared.cart?.checkoutURL { + // ShopifyCheckoutKit.preload(checkout: url) + // } } // MARK: UITableViewDataSource @@ -375,9 +375,9 @@ class CartViewController: UIViewController, UITableViewDelegate, UITableViewData self.setupCheckoutButtonContent() cell.quantityLabel.text = "\(cart.lines.nodes[indexPath.item].quantity)" - if let checkoutUrl = cart.checkoutURL { - ShopifyCheckoutKit.preload(checkout: checkoutUrl) - } + // if let checkoutUrl = cart.checkoutURL { + // ShopifyCheckoutKit.preload(checkout: checkoutUrl) + // } } } return cell diff --git a/platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift b/platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift index b6da73a9..599a7a2d 100644 --- a/platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift +++ b/platforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swift @@ -46,8 +46,8 @@ public func configure(_ block: (inout Configuration) -> Void) { block(&configuration) } -/// Preloads the checkout for faster presentation. -public func preload(checkout url: URL) { +/// Public preload support is coming soon. +internal func preload(checkout url: URL) { guard configuration.preloading.enabled else { return } From 9e4ef2f05bf9a8d5a2b9cf5098383c4bd0244a9b Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Thu, 14 May 2026 10:46:40 +0100 Subject: [PATCH 2/2] [Android] Hide preload from public API --- platforms/android/lib/api/lib.api | 1 - .../com/shopify/checkoutkit/ShopifyCheckoutKit.kt | 4 +++- .../cart/CartViewModel.kt | 14 +++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/platforms/android/lib/api/lib.api b/platforms/android/lib/api/lib.api index 268dcabb..50391ee4 100644 --- a/platforms/android/lib/api/lib.api +++ b/platforms/android/lib/api/lib.api @@ -3933,7 +3933,6 @@ public final class com/shopify/checkoutkit/ShopifyCheckoutKit { public static final fun configure (Lcom/shopify/checkoutkit/ConfigurationUpdater;)V public static final fun getConfiguration ()Lcom/shopify/checkoutkit/Configuration; public static final fun invalidate ()V - public static final fun preload (Ljava/lang/String;Landroidx/activity/ComponentActivity;)V public static final fun present (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lcom/shopify/checkoutkit/DefaultCheckoutEventProcessor;)Lcom/shopify/checkoutkit/CheckoutKitDialog; public static final fun present (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lcom/shopify/checkoutkit/DefaultCheckoutEventProcessor;Lcom/shopify/checkoutkit/CheckoutCommunicationClient;)Lcom/shopify/checkoutkit/CheckoutKitDialog; public static synthetic fun present$default (Ljava/lang/String;Landroidx/activity/ComponentActivity;Lcom/shopify/checkoutkit/DefaultCheckoutEventProcessor;Lcom/shopify/checkoutkit/CheckoutCommunicationClient;ILjava/lang/Object;)Lcom/shopify/checkoutkit/CheckoutKitDialog; diff --git a/platforms/android/lib/src/main/java/com/shopify/checkoutkit/ShopifyCheckoutKit.kt b/platforms/android/lib/src/main/java/com/shopify/checkoutkit/ShopifyCheckoutKit.kt index f01dffb1..3ba11ce1 100644 --- a/platforms/android/lib/src/main/java/com/shopify/checkoutkit/ShopifyCheckoutKit.kt +++ b/platforms/android/lib/src/main/java/com/shopify/checkoutkit/ShopifyCheckoutKit.kt @@ -89,9 +89,11 @@ public object ShopifyCheckoutKit { * * @param checkoutUrl The URL of the checkout to be loaded, this can be obtained via the Storefront API * @param context The context the checkout is being presented from + * + * Public preload support is coming soon. */ @JvmStatic - public fun preload(checkoutUrl: String, context: ComponentActivity) { + internal fun preload(checkoutUrl: String, context: ComponentActivity) { log.d("ShopifyCheckoutKit", "Preload called. Preloading enabled ${configuration.preloading.enabled}.") if (!configuration.preloading.enabled) return diff --git a/platforms/android/samples/MobileBuyIntegration/app/src/main/java/com/shopify/checkout_kit_mobile_buy_integration_sample/cart/CartViewModel.kt b/platforms/android/samples/MobileBuyIntegration/app/src/main/java/com/shopify/checkout_kit_mobile_buy_integration_sample/cart/CartViewModel.kt index dbe85084..56491617 100644 --- a/platforms/android/samples/MobileBuyIntegration/app/src/main/java/com/shopify/checkout_kit_mobile_buy_integration_sample/cart/CartViewModel.kt +++ b/platforms/android/samples/MobileBuyIntegration/app/src/main/java/com/shopify/checkout_kit_mobile_buy_integration_sample/cart/CartViewModel.kt @@ -127,13 +127,13 @@ class CartViewModel( fun preloadCheckout( activity: ComponentActivity, ) { - val state = _cartState.value - if (state is CartState.Cart) { - Timber.i("Preloading checkout with url ${state.checkoutUrl}") - ShopifyCheckoutKit.preload(state.checkoutUrl, activity) - } else { - Timber.i("Skipping checkout preload, cart is empty") - } + // val state = _cartState.value + // if (state is CartState.Cart) { + // Timber.i("Preloading checkout with url ${state.checkoutUrl}") + // ShopifyCheckoutKit.preload(state.checkoutUrl, activity) + // } else { + // Timber.i("Skipping checkout preload, cart is empty") + // } } fun continueShopping(navController: NavController) {