0

I am trying to do sms verification through react native where an OTP will be sent to a provided number. It worked when I was doing it normally in react native following this example https://www.npmjs.com/package/react-native-sms-android. But, the package only works for android, I want a solution which will work for both android and ios or ios. Is there any way?

Masuk Helal Anik
  • 2,155
  • 21
  • 29

2 Answers2

3

If someone is looking for an answer, starting iOS 12+, Apple introduced a new content input type oneTimeCode.

If you give the textContentType='oneTimeCode' to your text input, it will read the one time code from the message.

    <TextInput
      placeholder="Enter OTP"
      textContentType={'oneTimeCode'}
      value={input}
    />

Note, the message must contain either Passcode or code in the message and it shall start with <#>.

user1875926
  • 121
  • 11
1

No, It is not possible to access text messages in ios. I too suffered the same issue and ended up making an android app for the same. Apple doesn't let any application to access anything outside its sandbox. Until it, itself provides an API for that.

Ansh Gujral
  • 291
  • 1
  • 3
  • 13
  • I found this answer https://stackoverflow.com/questions/39631168/automatic-otp-verification-in-ios. But I have no idea how to implement that! – Masuk Helal Anik Mar 31 '19 at 07:08
  • As per the terms and conditions of Apple, it is not possible. I have done a lot of research. Apple is very strict with its policies. – Ansh Gujral Mar 31 '19 at 07:15