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.

48 lines (47 loc) 1.44 kB
"use strict"; import React, { useCallback, useEffect, useRef } from 'react'; import { findNodeHandle, NativeModules, Platform, requireNativeComponent, UIManager } from 'react-native'; import { jsx as _jsx } from "react/jsx-runtime"; const PurchaselyView = requireNativeComponent('PurchaselyView'); export const PLYPresentationView = ({ placementId, presentation, onPresentationClosed, flex = 1 }) => { const ref = useRef(null); const handlePresentationClosed = useCallback(result => { if (onPresentationClosed) { onPresentationClosed(result); } }, [onPresentationClosed]); NativeModules.PurchaselyView.onPresentationClosed().then(result => { handlePresentationClosed(result); }); useEffect(() => { if (Platform.OS === 'android') { const createFragment = viewId => UIManager.dispatchViewManagerCommand(viewId, // @ts-ignore UIManager.PurchaselyView.Commands.create.toString(), [viewId]); const viewId = findNodeHandle(ref.current); console.log('### viewId', viewId); if (viewId) { console.log('### creating Fragment'); createFragment(viewId); } } }, []); return /*#__PURE__*/_jsx(PurchaselyView // @ts-ignore , { style: { flex }, placementId: placementId, presentation: presentation, ...(Platform.OS === 'android' && { ref: ref }) }); }; //# sourceMappingURL=PLYPresentationView.js.map