React Native - Unable to get Android sms-otp autofill to work

3.6k Views Asked by At

I am using 0.66 (and also tried 0.68rc4) and am unable to get the autofill for otp to work on Android. Here is the component I have

<Input
  ...
  autoComplete="sms-otp"
  ...
/>

I tried the https://github.com/faizalshap/react-native-otp-verify library and it works, but am seeing if I can go with what RN provides if possible. The SMS is also appended with the correct app_hash, hence able to use the library above, but not with the out of box solution.

Does anyone have any suggestions?

1

There are 1 best solutions below

0
On

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"
/>

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