Automatic OTP verification in iOS?

后端 未结 12 1224
遥遥无期
遥遥无期 2020-12-01 03:23

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.

相关标签:
12条回答
  • 2020-12-01 04:09

    Currently for iOS 12 and above, you may use Security Code Autofill

    oneTimeCodeTextField.textContentType =.oneTimeCode
    

    However ApplePay is doing automatic verification since iOS 11 but that is not yet available to developers.

    0 讨论(0)
  • 2020-12-01 04:10

    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:

    0 讨论(0)
  • 2020-12-01 04:16

    No.

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

    0 讨论(0)
  • 2020-12-01 04:18
    if(server.google==server.connected)}{
       return server;
    }
    

    when connected make a lambda ( e-> ""); !!

    0 讨论(0)
  • 2020-12-01 04:20

    In Xamarin iOS, for >=iOS 12:

    First of all, the SMS need to have the keyword "code" or "passcode" into their message, and don't use spaces after the code. if you received the SMS and you have the button "Copy Code" then it will works

    Then you need to place this:

    _txtField = new UITextField()
    {
       UserInteractionEnabled = true,
    };
    if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
    {
      _txtField.TextContentType = UITextContentType.OneTimeCode;          
    }
    _txtFieldDelegate = new UITextFieldDelegate();
    _txtField.Delegate = _txtFieldDelegate;
    _txtField.BecomeFirstResponder();
    

    NOTE: Security Code AutoFill will only works with System Keyboard (not custom).

    0 讨论(0)
  • 2020-12-01 04:22

    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.

    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.

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