React Native How to auto fetched the OTP in the textfield from the mobile sms, should support both ios and android?
React Native How to auto fetched the OTP in the textfield from the mobile sms,should support both ios and android?
Asked Answered
How do you send the SMS? Are you using firebase by any chance? Firebase has an auto verification mechanism which would feel the same as "auto fetch OTP". –
Farr
For Android : Google SMS Retriever API
https://github.com/Rajat421//react-native-sms-retriever-api#readme
For iOS :
You will use props textContentType of TextInput
<TextInput
value={this.state.codeOTP}
textContentType="oneTimeCode"
/>
You can test before with this example :
Tested on real device, and connect with the Apple account
<TextInput
value={this.state.codeOTP}
textContentType="emailAddress"
/>
Native support added for react-native versions 0.66+!!
<TextInput
...
autoComplete="one-time-code"
/>
This isn't working for me. Is this still valid ? –
Hebner
Currently there is no support for ios till now for otp auto read functionality using react-native.
But for android you can use this library: https://github.com/faizalshap/react-native-otp-verify#readme
cannot install the packege react-native-otp-verify,error occur after linking ,as cannot find symbol import com.faizal.OtpVerify.RNOtpVerifyPackage; –
Miley
© 2022 - 2024 — McMap. All rights reserved.