@olo/pay-react-native
Version:
Olo Pay React Native SDK
44 lines (41 loc) • 1.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOloPayNativeModule;
var _reactNative = require("react-native");
// Copyright © 2022 Olo Inc. All rights reserved.
// This software is made available under the Olo Pay SDK License (See LICENSE.md file)
const LINKING_ERROR = `The package '@olo/pay-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
ios: "- You have run 'pod install'\n",
default: ''
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
// Try to use the TurboModule if available (New Architecture)
// Fall back to NativeModules if not (Old Architecture)
// @ts-ignore
const isTurboModuleEnabled = global.__turboModuleProxy != null;
let OlopaysdkReactNative;
if (isTurboModuleEnabled) {
try {
// Dynamic import to avoid errors in Old Architecture
const NativeModule = require('../NativeOlopaysdkReactNative').default;
OlopaysdkReactNative = NativeModule;
} catch (e) {
// If TurboModule import fails, fall back to NativeModules
OlopaysdkReactNative = _reactNative.NativeModules.OlopaysdkReactNative ? _reactNative.NativeModules.OlopaysdkReactNative : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
}
} else {
OlopaysdkReactNative = _reactNative.NativeModules.OlopaysdkReactNative ? _reactNative.NativeModules.OlopaysdkReactNative : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
}
function useOloPayNativeModule() {
return OlopaysdkReactNative;
}
//# sourceMappingURL=useOloPayNativeModule.js.map