UNPKG

@msg91comm/react-native-sendotp

Version:

The SendOtp Verification SDK makes verifying phone numbers easy. SDK supports the verification of phone numbers via SMS & Calls.

63 lines (59 loc) 1.32 kB
export const sendOtp = (input : string) => `(function() { window.sendOtp( '${input}', (data) => { window.ReactNativeWebView.postMessage(JSON.stringify(data)); }, (error) => { window.ReactNativeWebView.postMessage(JSON.stringify(error)); } ); })(); true `; export const retryOtp = (retryOn? : 'SMS' | 'VOICE' | 'EMAIL' | 'WHATSAPP') => { let retryCode: string | null = null; if(retryOn == 'SMS'){ retryCode = '11'; } else if(retryOn == 'VOICE'){ retryCode = '4'; } else if(retryOn == 'EMAIL'){ retryCode = '3'; } else if (retryOn == 'WHATSAPP'){ retryCode = '12'; } else{ retryCode = null; } return ( `(function() { window.retryOtp( ${retryCode}, (data) => { window.ReactNativeWebView.postMessage(JSON.stringify(data)); }, (error) => { window.ReactNativeWebView.postMessage(JSON.stringify(error)); } ); })(); true; ` ) }; export const verifyOtp = (otp : number) => `(function() { window.verifyOtp( ${otp}, (data) => { window.ReactNativeWebView.postMessage(JSON.stringify(data)); }, (error) => { window.ReactNativeWebView.postMessage(JSON.stringify(error)); } ); })(); true `;