Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 12短信阅读API?_Ios_Sms_Ios12 - Fatal编程技术网

iOS 12短信阅读API?

iOS 12短信阅读API?,ios,sms,ios12,Ios,Sms,Ios12,在iOS 12的测试版中,我观察到它在键盘建议中给出了OTP(来自SMS)。 那么,有没有他们为开发人员创建的API呢?或者这只是一个操作系统功能。没有api,但您需要将textconttype设置为.oneTimeCode的UITextField属性 otpTextField.textContentType = .oneTimeCode 还有一件事 如果对文本字段使用自定义输入视图, iOS无法显示必要的自动填充UI 这是操作系统的功能,但您需要设置UITextField的输入视图的text

在iOS 12的测试版中,我观察到它在键盘建议中给出了OTP(来自SMS)。

那么,有没有他们为开发人员创建的API呢?或者这只是一个操作系统功能。

没有api,但您需要将
textconttype
设置为
.oneTimeCode
UITextField
属性

otpTextField.textContentType = .oneTimeCode
还有一件事

如果对文本字段使用自定义输入视图, iOS无法显示必要的自动填充UI


这是操作系统的功能,但您需要设置
UITextField
的输入视图的
textContentType
属性
oneTimeCode

otpTextField.textContentType = .oneTimeCode
注意:安全码自动填充仅适用于系统键盘,不适用于自定义键盘

当您获得OTP时,它将如下所示:


不幸的是,您无法阅读完整消息,只能阅读消息中的验证代码

Swift:

@available(iOS 12.0, *)
public static let oneTimeCode: UITextContentType

myTextField.textContentType = .oneTimeCode
UITextContentType const UITextContentTypeOneTimeCode NS_AVAILABLE_IOS(12_0);

myTextField.textContentType = UITextContentTypeOneTimeCode;
目标-C:

@available(iOS 12.0, *)
public static let oneTimeCode: UITextContentType

myTextField.textContentType = .oneTimeCode
UITextContentType const UITextContentTypeOneTimeCode NS_AVAILABLE_IOS(12_0);

myTextField.textContentType = UITextContentTypeOneTimeCode;

系统可以识别以下验证代码:

长度为3-8的纯数

比如:1231234 12345 666666 1234567 12345678


系统无法识别以下验证代码:

(i).代码长度小于3或大于8 (ii).包括字母

比如:11223A 9h7d 123456789


其他:


安全码自动填充仅适用于系统键盘。它不适用于自定义键盘。

不,没有用于此的公共API。它是由操作系统自动处理的。 您只需要将UITextField的输入视图的textContentType属性设置为oneTimeCode


textField.textContentType=.oneTimeCode

添加到其他答案中,测试后,文本消息似乎需要在数字前包含“验证号”或“代码”才能正常工作

工作:

  • 验证号1234
  • 验证号码:1234
  • 验证码1234
  • 验证码:1234
  • 代码1234
  • 代码:1234
  • 检察官办公室1234
  • 检察官办公室:1234
不工作:

  • 1234号
  • 核查1234
  • 1234

值得一提的是,手机上似乎需要打开“自动填充密码”键盘选项。

您的信息来源是什么?我们能得到一个链接吗?@MichaelOzeryansky你是说测试信息吗?没有消息来源。这是我自己测试的结果。黄色文本,符号“>”,用于引用某些内容。我问是因为你好像引用了一些参考资料。我还看到短信的字符限制是70个@mattyU你在哪里看到的?