UNPKG

trustly-react-native-webview

Version:

Trustly ReactNative WebView needed when integrating Trustly Checkout in a ReactNative application.

28 lines (25 loc) 832 B
export const NativeEventTypes = { SUCCESS: 'onTrustlyCheckoutSuccess', ERROR: 'onTrustlyCheckoutError', REDIRECT: 'onTrustlyCheckoutRedirect', ABORT: 'onTrustlyCheckoutAbort', }; export const trustlyApplicationName = 'TrustlyReactNativeWebView/v1'; export const trustlyCustomBridge = ` window.addEventListener('message', (e) => { try { const data = e.data; const message = typeof data !== 'string' ? JSON.stringify(data) : data; if (window.ReactNativeWebView) { window.ReactNativeWebView.postMessage(message, '*'); } } catch (e) { console.log('An error occurred while trying to handle message from Trustly SDK listener: ', e.message); } }); /* NOTE: this is required, or you'll sometimes get silent failures */ true; `;