Autofill OTP to the TextField when I receive message iPhone app
Asked Answered
J

2

14

While registering from my app I was sending OTP to the registered mobile number I want to retrieve that OTP in my app without opening SMS app...When the user received OTP message I need to display that OTP here ...How can I achieve this in iOS? I also have user Phone number with me.

On search, I have found this but I am not clear how to initiate this. Can anyone help me from this?

Jaguarundi answered 2/11, 2015 at 7:47 Comment(6)
What you found? Can you share the link?Mollescent
#20902301Jaguarundi
Reading SMS is not possible in iOS. Check this, https://mcmap.net/q/741570/-iphone-application-reading-smsMollescent
But from the above link i can see that we can access SMS ?Jaguarundi
That may be done through jail broken device. But not sure.Mollescent
Is there any update for iOS10?Perversity
M
11

You cannot access messages on ios and hence you cannot autofill the OTP in ios apps by reading sms.

The answers in the link that you have posted do not read the sms messages. They just create a custom url scheme and the otp is filled in when the user clicks the custom url in the sms.

Meadow answered 6/1, 2016 at 8:9 Comment(2)
@TLuck i just update iOS 10.1 and in it I enable two way authentication, and apple own application can read it and auto fill OTP, for me, I do not know they make it open for developer or not.Rheotaxis
I think apps should not allow to read messages. It can be security breach. As you may have some secure & sensitive information. Such as Bank informationDurham
H
12

UPDATE

From iOS 12 Apple will allow the support to read One Time Code(OTP - One Time Password) which you will get in the iPhone device.

iOS supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol. System keyboard set the textContentType on it to .oneTimeCode

1) Using Code

singleFactorCodeTextField.textContentType = .oneTimeCode

2) Using Storyboard/XIB

Select UITextField/UITextView in storyboard/XIB click Click on Attribute inspector. Go to text input trait, click to Content type and select one time code and done.

The operating system will detect verification codes from Messages automatically with this UITextContentType set.

Check out the official documentation for Enabling Password AutoFill on a Text Input View

Hayleyhayloft answered 11/10, 2018 at 10:44 Comment(1)
in my case this is working only for UItextfield but not for UItextView, could you share working demo for UITextview ?Iveson
M
11

You cannot access messages on ios and hence you cannot autofill the OTP in ios apps by reading sms.

The answers in the link that you have posted do not read the sms messages. They just create a custom url scheme and the otp is filled in when the user clicks the custom url in the sms.

Meadow answered 6/1, 2016 at 8:9 Comment(2)
@TLuck i just update iOS 10.1 and in it I enable two way authentication, and apple own application can read it and auto fill OTP, for me, I do not know they make it open for developer or not.Rheotaxis
I think apps should not allow to read messages. It can be security breach. As you may have some secure & sensitive information. Such as Bank informationDurham

© 2022 - 2024 — McMap. All rights reserved.