UNPKG

react-native-purchasely

Version:

Purchasely is a solution to ease the integration and boost your In-App Purchase & Subscriptions on the App Store, Google Play Store and Huawei App Gallery.

54 lines (53 loc) 2.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PLYPresentationView = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } const PurchaselyView = (0, _reactNative.requireNativeComponent)('PurchaselyView'); const PLYPresentationView = ({ placementId, presentation, onPresentationClosed, flex = 1 // Default to 1 if not provided }) => { const ref = (0, _react.useRef)(null); (0, _react.useEffect)(() => { if (!onPresentationClosed) return; const handleClose = async () => { const result = await _reactNative.NativeModules.PurchaselyView.onPresentationClosed(); onPresentationClosed(result); }; handleClose(); }, [onPresentationClosed]); (0, _react.useEffect)(() => { if (_reactNative.Platform.OS === 'android') { const createFragment = viewId => _reactNative.UIManager.dispatchViewManagerCommand(viewId, // @ts-ignore _reactNative.UIManager.PurchaselyView.Commands.create.toString(), [viewId]); const viewId = (0, _reactNative.findNodeHandle)(ref.current); console.log('### viewId', viewId); if (viewId) { console.log('### creating Fragment'); createFragment(viewId); } } }, []); return /*#__PURE__*/(0, _jsxRuntime.jsx)(PurchaselyView // @ts-ignore , { style: { flex }, placementId: placementId, presentation: presentation, ...(_reactNative.Platform.OS === 'android' && { ref: ref }) }); }; exports.PLYPresentationView = PLYPresentationView; //# sourceMappingURL=PLYPresentationView.js.map