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.
55 lines (54 loc) • 2.45 kB
JavaScript
;
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 _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const PurchaselyView = (0, _reactNative.requireNativeComponent)('PurchaselyView');
const PLYPresentationView = ({
placementId,
presentation,
onPresentationClosed,
flex = 1
}) => {
const ref = (0, _react.useRef)(null);
const handlePresentationClosed = (0, _react.useCallback)(result => {
if (onPresentationClosed) {
onPresentationClosed(result);
}
}, [onPresentationClosed]);
_reactNative.NativeModules.PurchaselyView.onPresentationClosed().then(result => {
handlePresentationClosed(result);
});
(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