iOS 12 SMS Reading API?

前端 未结 6 851
既然无缘
既然无缘 2021-01-12 01:07

In Beta version of iOS 12 I have observed it gives OTP(from SMS) in keyboard suggestion.
So is there any API which they have created for developers ? Or that would just

6条回答
  •  离开以前
    2021-01-12 01:44

    Unfortunately, you can't read the full message, you can only read the verify-code in the message.

    Swift:

    @available(iOS 12.0, *)
    public static let oneTimeCode: UITextContentType
    
    myTextField.textContentType = .oneTimeCode
    

    Objective-C:

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

    These following verification code CAN be recognized by the system:

    A pure number of lengths of 3-8

    like : 123 1234 12345 666666 1234567 12345678 ...


    These following verification code CANNOT be recognized by the system:

    (i).length of code is less than 3 or more than 8 (ii).include letters

    like : 1 12 123a 9h7d 123456789 ...


    Others:

    Security Code AutoFill will only works with System Keyboard. It will not work with custom keyboard.

提交回复
热议问题