UNPKG

react-native-knotapi

Version:

Provide a seamless way for end users to link their merchant accounts to your mobile app.

34 lines (33 loc) 1.09 kB
"use strict"; import { NativeModules, Platform, NativeEventEmitter, InteractionManager } from 'react-native'; const LINKING_ERROR = `The package 'react-native-knotapi' doesn't seem to be linked. Make sure: \n\n` + 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'; const Knotapi = NativeModules.Knotapi ? NativeModules.Knotapi : new Proxy({}, { get() { throw new Error(LINKING_ERROR); } }); const eventEmitter = new NativeEventEmitter(Knotapi); export const Knot = { open: params => { InteractionManager.runAfterInteractions(() => { Knotapi?.open(params); }); }, openWithoutDelay: params => { Knotapi?.open(params); }, close: () => { Knotapi?.close(); }, getSdkVersion: () => { return Knotapi?.getSdkVersion() ?? undefined; } }; export const addKnotListener = (eventName, callback) => { return eventEmitter.addListener(`${eventName}`, callback); }; export default Knotapi; //# sourceMappingURL=index.js.map