React Native How to auto fetched the OTP in the textfield from the mobile sms,should support both ios and android?
Asked Answered
M

3

15

React Native How to auto fetched the OTP in the textfield from the mobile sms, should support both ios and android?

Miley answered 28/3, 2019 at 8:42 Comment(1)
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
P
9

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"
/>
Puffin answered 20/5, 2019 at 14:35 Comment(0)
A
6

Native support added for react-native versions 0.66+!!

autoComplete prop.

<TextInput
    ...
    autoComplete="one-time-code"
/>
Austronesia answered 22/1, 2022 at 18:1 Comment(1)
This isn't working for me. Is this still valid ?Hebner
B
1

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

Brotherson answered 28/3, 2019 at 9:6 Comment(1)
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.