Read SMS message in iOS

后端 未结 5 944
情书的邮戳
情书的邮戳 2020-12-05 13:42

I\'m an iOS developer and i have tried to build a mobile application with automatic activation functionality, i found more than way to read SMS message but only using privat

相关标签:
5条回答
  • 2020-12-05 14:21

    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

    • 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.

    It only works with System keyboard. So avoid using the custom keyboard.


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

    0 讨论(0)
  • 2020-12-05 14:21

    Support - Since iOS 12

    Flow, Automatically fill in SMS passcodes on iPhone - https://support.apple.com/en-in/guide/iphone/iphc89a3a3af/13.0/ios/13.0

    Implementation Guide - https://developer.apple.com/documentation/security/password_autofill/enabling_password_autofill_on_a_text_input_view

    When you sign in to some apps and websites, a one-time SMS passcode is sent to your iPhone. As a security measure, you are required to enter the code into the app or website. iPhone can detect the passcode in Messages and display it above the keyboard.

    To use the passcode, tap it.

    0 讨论(0)
  • 2020-12-05 14:23
    1. No, there is no way to read SMS messages. Apple is very strict on this due to privacy concerns.
    2. Log in to the developers portal and click App Store Review Guidelines.

    Nowhere in the guidelines does it specify that you can't access the SMSes. But you can only access if you use private methods which is not allowed and will get your app rejected.

    You can only access data for which Apple supplies a documented API. You can not access files outside of the Sandbox of your App unless Apple provides an API for it.

    0 讨论(0)
  • 2020-12-05 14:33

    For Swift 5:

    From iOS 12 Apple has given support to read the security code (OTP - One Time Passwords) in text fields.

    if #available(iOS 12.0, *) {
                   otpField.keyboardType = .default
                   otpField.textContentType = .oneTimeCode
           } else {
                   // Fallback on earlier versions
    
           }
    

    Or you can add this contentType from storyboard like below:

    0 讨论(0)
  • 2020-12-05 14:47

    UPDATE

    From iOS 12 Apple has given support to read the security code (OTP - One Time Passwords) in text fields.

    oneTimeCode

    Specifies the expectation of a single-factor SMS login code.

    You can autocomplete security codes from single-factor SMS login flows:

    yourSingleFactorCodeTextField.textContentType = .oneTimeCode
    

    iOS supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol.

    Warning

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

    0 讨论(0)
提交回复
热议问题