Automatic OTP verification in iOS?

2019-03-09 11:24发布

Is there any way to access data from iPhone inbox(SMS) to ios application to do automatic OTP verification like the one in Android? I shall be grateful for your help.

7条回答
闹够了就滚
2楼-- · 2019-03-09 11:57

you can easily set this in Storyboard

Click on Attribute inspector. Go to text input trait, click on Content type and select one time code

查看更多
ゆ 、 Hurt°
3楼-- · 2019-03-09 12:00

UPDATE

From iOS 12 Apple will 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.

Warning

If you use a custom input view for a security code input text field, iOS cannot display the necessary AutoFill UI.

WWDC 2018 iPhoneX Device

For more information, you can check it on the Apple developer oneTimeCode

And also review WWDC 2018 Session 204 - Automatic Strong Passwords and Security Code AutoFill and jump to 24:28 for automatic pre-fill the OTP.

查看更多
Animai°情兽
4楼-- · 2019-03-09 12:01

UPDATE

This is now possible in iOS 12 with Security Code Autofill

Apple is using it in apple pay card verification since iOS 11

enter image description here

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-03-09 12:04

No.

Because this would be considered a privacy issue, you cannot access the users SMS inbox.

查看更多
祖国的老花朵
6楼-- · 2019-03-09 12:07

You can get OTP from your message.

otptextField.textContentType = .oneTimeCode

Can please get the project from his link.

https://github.com/karthickkck315/Automatic-OTP

查看更多
萌系小妹纸
7楼-- · 2019-03-09 12:15

In iOS 12 Apple has introduced feature called Security Code AutoFill.

To use this in your app all you need to do is set UITextField's input view’s textContentType property oneTimeCode.

otpTextField.textContentType = .oneTimeCode

NOTE: Security Code AutoFill will only works with System Keyboard it will not work with custom keyboard.

WWDC video

When you get OTP it will look something like this:

enter image description here

查看更多
登录 后发表回答