I want to read an opt from a text message and fill it automatically on the screen.
I came across this article on stackoverflow reading-otp.All the comments in there talk entirely of the options that we can use on a TextInput Field for both ios and android.
But I believe if we want to automatically fill the input without any user interaction, we need to have some kind of listener that should get the value or the message from which we can extract the otp and set the value of the field.
Related to this I got to know to this package react-native-otp-verify), but this package is only for android. It provides the listeners and the way to listen for the value and set it automatically.
But I did not find any such package or anything for IOS that allows us to set listeners that can be used to receive the value. Do I need to write a native module for this?
I created a text input as follows
<TextInput
value={codeOTP}
autoComplete="sms-otp" // android
textContentType="oneTimeCode" // ios
/>
where codeOTP is a state variable. I am also aware that the structure of the message needs to be something like this
<#> Your code is: 123ABC78
FA+9qCX9VSu
Also I am not completely sure on how to generate the hash. For android we have the above mentioned package but for ios I did not find any resources.
Also there are other articles like this on stackoverflow but all of them mention solutions for android, not much is described about ios.