Automatic OTP verification in iOS?

后端 未结 12 1273
遥遥无期
遥遥无期 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: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).

提交回复
热议问题