Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
9 changes: 1 addition & 8 deletions modules/@shopify/checkout-sheet-kit/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -62,14 +62,8 @@ public ShopifyCheckoutSheetKitModule(ReactApplicationContext reactContext) {
});
}

@NonNull
@Override
public String getName() {
return MODULE_NAME;
}

@Override
public Map<String, Object> getConstants() {
protected Map<String, Object> getTypedExportedConstants() {
final Map<String, Object> constants = new HashMap<>();
constants.put("version", ShopifyCheckoutSheetKit.version);
return constants;
Expand All @@ -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
}

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,52 @@ 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
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactContext) {
return Collections.emptyList();
}

@NonNull
@Nullable
@Override
public List<NativeModule> createNativeModules(
@NonNull ReactApplicationContext reactContext) {
List<NativeModule> 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<String, ReactModuleInfo> moduleInfos = new HashMap<>();
moduleInfos.put(
ShopifyCheckoutSheetKitModule.NAME,
new ReactModuleInfo(
ShopifyCheckoutSheetKitModule.NAME,
ShopifyCheckoutSheetKitModule.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
false, // isCxxModule
true // isTurboModule
));
return moduleInfos;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ of this software and associated documentation files (the "Software"), to deal

#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>
#import <RNShopifyCheckoutSheetKitSpec/RNShopifyCheckoutSheetKitSpec.h>

@interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NSObject)
@interface RCT_EXTERN_MODULE (RCTShopifyCheckoutSheetKit, NativeShopifyCheckoutSheetKitSpecBase)

/**
* Present checkout
Expand Down Expand Up @@ -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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class RCTShopifyCheckoutSheetKit: RCTEventEmitter, CheckoutDelegate {
]
}

@objc func getConstants() -> [AnyHashable: Any]! {
return constantsToExport()
}

static func getRootViewController() -> UIViewController? {
return (
UIApplication.shared.connectedScenes
Expand Down Expand Up @@ -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, *)
Expand Down
Loading