简体   繁体   English

当我收到消息 iPhone 应用程序时自动填充文本字段的 OTP

[英]Autofill OTP to the TextField when I receive message iPhone app

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?从我的应用程序注册时,我将 OTP 发送到注册的手机号码我想在我的应用程序中检索该 OTP,而无需打开 SMS 应用程序...当用户收到 OTP 消息时,我需要在此处显示该 OTP...我该如何实现这在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?任何人都可以帮助我吗?

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 12 开始,Apple 将支持读取您将在 iPhone 设备中获得的一次性代码(OTP - 一次性密码)。

iOS supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol. iOS 支持 UITextField、UITextView 和任何采用 UITextInput 协议的自定义视图上的密码自动填充。 System keyboard set the textContentType on it to .oneTimeCode系统键盘将其上的 textContentType 设置为.oneTimeCode

1) Using Code 1) 使用代码

singleFactorCodeTextField.textContentType = .oneTimeCode

2) Using Storyboard/XIB 2) 使用故事板/XIB

Select UITextField/UITextView in storyboard/XIB click Click on Attribute inspector.storyboard/XIB选择UITextField/UITextView点击属性检查器。 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.操作系统将使用此 UITextContentType 集自动检测消息中的验证码。

Check out the official documentation for Enabling Password AutoFill on a Text Input View查看在文本输入视图上启用密码自动填充的官方文档

You cannot access messages on ios and hence you cannot autofill the OTP in ios apps by reading sms.您无法在 ios 上访问消息,因此您无法通过阅读短信在 ios 应用程序中自动填充 OTP。

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.他们只是创建一个自定义 url 方案,当用户点击sms 中的自定义 url otp 就会被填充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM