From 14eb240f9e7e24cee0f9981adde1a51cab05e772 Mon Sep 17 00:00:00 2001 From: Kieran Osgood Date: Mon, 30 Mar 2026 15:23:31 +0100 Subject: [PATCH] feat: replace interop with new arch code --- .../RNShopifyCheckoutSheetKit.podspec | 38 +++++++--------- .../checkout-sheet-kit/android/build.gradle | 9 +--- .../ShopifyCheckoutSheetKitModule.java | 45 ++++++++++++++----- .../ShopifyCheckoutSheetKitPackage.java | 41 ++++++++++++----- .../ios/ShopifyCheckoutSheetKit.mm | 8 +++- .../ios/ShopifyCheckoutSheetKit.swift | 8 ++++ 6 files changed, 95 insertions(+), 54 deletions(-) diff --git a/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec b/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec index b73322d1..f197a7c1 100644 --- a/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec +++ b/modules/@shopify/checkout-sheet-kit/RNShopifyCheckoutSheetKit.podspec @@ -4,8 +4,6 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json"))) folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' -fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' - Pod::Spec.new do |s| s.name = "RNShopifyCheckoutSheetKit" s.version = package["version"] @@ -23,25 +21,21 @@ Pod::Spec.new do |s| s.dependency "ShopifyCheckoutSheetKit", "~> 3.6.0" s.dependency "ShopifyCheckoutSheetKit/AcceleratedCheckouts", "~> 3.6.0" - if fabric_enabled - # Use React Native's helper if available, otherwise add dependencies directly - if defined?(install_modules_dependencies) - install_modules_dependencies(s) - else - # Fallback: manually specify dependencies for New Architecture - s.dependency "React-Codegen" - s.dependency "RCT-Folly", :modular_headers => true - s.dependency "RCTRequired" - s.dependency "RCTTypeSafety" - s.dependency "ReactCommon/turbomodule/core" - end - - s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" - - s.pod_target_xcconfig = { - "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", - "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", - "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" - } + if defined?(install_modules_dependencies) + install_modules_dependencies(s) + else + s.dependency "React-Codegen" + s.dependency "RCT-Folly", :modular_headers => true + s.dependency "RCTRequired" + s.dependency "RCTTypeSafety" + s.dependency "ReactCommon/turbomodule/core" end + + s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1" + + s.pod_target_xcconfig = { + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"", + "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" + } end diff --git a/modules/@shopify/checkout-sheet-kit/android/build.gradle b/modules/@shopify/checkout-sheet-kit/android/build.gradle index 82b9a034..dd55f324 100644 --- a/modules/@shopify/checkout-sheet-kit/android/build.gradle +++ b/modules/@shopify/checkout-sheet-kit/android/build.gradle @@ -9,15 +9,8 @@ buildscript { } } -def isNewArchitectureEnabled() { - return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true" -} - apply plugin: "com.android.library" - -if (isNewArchitectureEnabled()) { - apply plugin: "com.facebook.react" -} +apply plugin: "com.facebook.react" def getExtOrIntegerDefault(name) { return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties[name]).toInteger() diff --git a/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java b/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java index 53dd39e2..8c5c3196 100644 --- a/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java +++ b/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitModule.java @@ -29,19 +29,19 @@ of this software and associated documentation files (the "Software"), to deal import androidx.annotation.NonNull; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; import com.facebook.react.bridge.WritableMap; +import com.shopify.checkoutsheetkit.NativeShopifyCheckoutSheetKitSpec; import com.shopify.checkoutsheetkit.*; import java.util.HashMap; import java.util.Map; import java.util.Objects; -public class ShopifyCheckoutSheetKitModule extends ReactContextBaseJavaModule { - private static final String MODULE_NAME = "ShopifyCheckoutSheetKit"; +public class ShopifyCheckoutSheetKitModule extends NativeShopifyCheckoutSheetKitSpec { public static Configuration checkoutConfig = new Configuration(); @@ -62,14 +62,8 @@ public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) { }); } - @NonNull @Override - public String getName() { - return MODULE_NAME; - } - - @Override - public Map getConstants() { + protected Map getTypedExportedConstants() { final Map constants = new HashMap<>(); constants.put("version", ShopifyCheckoutSheetKit.version); return constants; @@ -81,7 +75,7 @@ public void addListener(String eventName) { } @ReactMethod - public void removeListeners(Integer count) { + public void removeListeners(double count) { // No-op but required for RN to register module } @@ -172,7 +166,34 @@ public void setConfig(ReadableMap config) { } @ReactMethod - public void initiateGeolocationRequest(Boolean allow) { + public void configureAcceleratedCheckouts( + String storefrontDomain, + String storefrontAccessToken, + String customerEmail, + String customerPhoneNumber, + String customerAccessToken, + String applePayMerchantIdentifier, + ReadableArray applyPayContactFields, + ReadableArray supportedShippingCountries, + Promise promise) { + // Accelerated checkouts not supported on Android + promise.resolve(false); + } + + @ReactMethod + public void isAcceleratedCheckoutAvailable(Promise promise) { + // Accelerated checkouts not supported on Android + promise.resolve(false); + } + + @ReactMethod + public void isApplePayAvailable(Promise promise) { + // Apple Pay not available on Android + promise.resolve(false); + } + + @ReactMethod + public void initiateGeolocationRequest(boolean allow) { if (checkoutEventProcessor != null) { checkoutEventProcessor.invokeGeolocationCallback(allow); } diff --git a/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitPackage.java b/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitPackage.java index 5300fb63..f6cda161 100644 --- a/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitPackage.java +++ b/modules/@shopify/checkout-sheet-kit/android/src/main/java/com/shopify/reactnative/checkoutsheetkit/ShopifyCheckoutSheetKitPackage.java @@ -24,17 +24,21 @@ of this software and associated documentation files (the "Software"), to deal package com.shopify.reactnative.checkoutsheetkit; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; -import com.facebook.react.ReactPackage; +import com.facebook.react.TurboReactPackage; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; +import com.facebook.react.module.model.ReactModuleInfo; +import com.facebook.react.module.model.ReactModuleInfoProvider; import com.facebook.react.uimanager.ViewManager; -import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; -public class ShopifyCheckoutSheetKitPackage implements ReactPackage { +public class ShopifyCheckoutSheetKitPackage extends TurboReactPackage { @NonNull @Override @@ -42,15 +46,30 @@ public List createViewManagers(@NonNull ReactApplicationContext rea return Collections.emptyList(); } - @NonNull + @Nullable @Override - public List createNativeModules( - @NonNull ReactApplicationContext reactContext) { - List modules = new ArrayList<>(); - - modules.add(new ShopifyCheckoutSheetKitModule(reactContext)); - - return modules; + public NativeModule getModule(@NonNull String name, @NonNull ReactApplicationContext reactContext) { + if (name.equals(ShopifyCheckoutSheetKitModule.NAME)) { + return new ShopifyCheckoutSheetKitModule(reactContext); + } + return null; } + @Override + public ReactModuleInfoProvider getReactModuleInfoProvider() { + return () -> { + final Map moduleInfos = new HashMap<>(); + moduleInfos.put( + ShopifyCheckoutSheetKitModule.NAME, + new ReactModuleInfo( + ShopifyCheckoutSheetKitModule.NAME, + ShopifyCheckoutSheetKitModule.NAME, + false, // canOverrideExistingModule + false, // needsEagerInit + false, // isCxxModule + true // isTurboModule + )); + return moduleInfos; + }; + } } diff --git a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm index 2971cd2c..05fe04e8 100644 --- a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm +++ b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.mm @@ -24,8 +24,9 @@ of this software and associated documentation files (the "Software"), to deal #import #import +#import -@interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NSObject) +@interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NativeShopifyCheckoutSheetKitSpecBase) /** * Present checkout @@ -77,6 +78,11 @@ @interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NSObject) */ RCT_EXTERN_METHOD(isApplePayAvailable : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); +/** + * Respond to geolocation permission request + */ +RCT_EXTERN_METHOD(initiateGeolocationRequest : (BOOL)allow); + @end /** diff --git a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift index 25425e7c..200f505c 100644 --- a/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift +++ b/modules/@shopify/checkout-sheet-kit/ios/ShopifyCheckoutSheetKit.swift @@ -103,6 +103,10 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate { ] } + @objc func getConstants() -> [AnyHashable: Any]! { + return constantsToExport() + } + static func getRootViewController() -> UIViewController? { return ( UIApplication.shared.connectedScenes @@ -302,6 +306,10 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate { resolve(available) } + @objc func initiateGeolocationRequest(_ allow: Bool) { + // No-op on iOS — geolocation permission is handled natively + } + // MARK: - Private @available(iOS 16.0, *)