Closed aakash-3990 closed 2 years ago
*To achieve the auto verification in react native I had been used the react-native-OTP-verify library But I not able to achieve it in my App. Please help me with the same. **My code is** import RNOtpVerify from 'react-native-otp-verify'; componentDidMount() { if (Platform.OS === 'android') { this.getHash(); this.startListeningForOtp(); } } componentWillUnmount() { RNOtpVerify.removeListener(); } getHash = () => { RNOtpVerify.getHash() .then(console.log) .catch(console.log); } startListeningForOtp = () => { RNOtpVerify.getOtp() .then(p => RNOtpVerify.addListener(this.otpHandler)) .catch(p => console.log(p)); } otpHandler = (message) => { if(message){ const otp = /(\d{6})/g.exec(message)[1]; this.setState({otp}); RNOtpVerify.removeListener(); Keyboard.dismiss(); } } render() { const {otp, userName} = this.state; return ( <TextInput // placeholder="Enter OTP" style={styles.otpTextInput} autoComplete='sms-otp' // for android textContentType='oneTimeCode' //for ios keyboardType="numeric" autoFocus={true} maxLength={6} value={otp} letterSpacing={12} onChangeText={code => this.setState({otp: code})} /> );
In this I get only the hash key but I don't know where I can use it Please guide me for the same.*
I am using this library to achieve the auto verification in react native.
enter code here
Hi @aakash-3990 you need to add that hash in the sms please read documentation from google that is mentioned in readme thanks
In this I get only the hash key but I don't know where I can use it Please guide me for the same.*
I am using this library to achieve the auto verification in react native.