Xamarin.ios Xamarin iOS中的UITextContentType.OneTimeCode

Xamarin.ios Xamarin iOS中的UITextContentType.OneTimeCode,xamarin.ios,Xamarin.ios,我正在尝试在我的应用程序中实现OTC。我正在做下一个: _txtField = new UITextField() { UserInteractionEnabled = true, TextContentType = UITextContentType.OneTimeCode }; _txtFieldDelegate = new UITextFieldDelegate(); _txtField.Delegate = _txtFieldDelegate; 我收到了短信,但我没有任何东

我正在尝试在我的应用程序中实现OTC。我正在做下一个:

_txtField = new UITextField()
{
   UserInteractionEnabled = true,
   TextContentType = UITextContentType.OneTimeCode
};
_txtFieldDelegate = new UITextFieldDelegate();
_txtField.Delegate = _txtFieldDelegate;

我收到了短信,但我没有任何东西可以填充文本字段,我还需要什么才能让它工作?

首先,
OneTimeCode
在iOS 12.0之后可用。因此,添加以下代码

if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
{
  _txtField.TextContentType = UITextContentType.OneTimeCode;          
}
发送get SMS请求后,将文本字段设置为
BecomeFirstResponder

 _txtField.BecomeFirstResponder();

然后,SMS代码将出现在键盘上。当您单击它时,它将自动填充。

首先,
OneTimeCode
在iOS 12.0之后可用。因此,添加以下代码

if (UIDevice.CurrentDevice.CheckSystemVersion(12, 0))
{
  _txtField.TextContentType = UITextContentType.OneTimeCode;          
}
发送get SMS请求后,将文本字段设置为
BecomeFirstResponder

 _txtField.BecomeFirstResponder();

然后,SMS代码将出现在键盘上。当您单击它时,它将自动填充。

它可以工作,但主要问题是SMS,文本中必须有“code”或“Passcode”键。它可以工作,但主要问题是SMS,文本中必须有“code”或“Passcode”键。