Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 12 - oneTimeCode OTP delegate

Is there any delegate getting fired when the user taps the OTP suggestion that iOS provides?

I know that I could use UITextFieldDelegate methods to detect changes in the textfield's text property, but knowing that the user has pressed the button would make things so much easier...

like image 828
jdev Avatar asked Oct 19 '25 01:10

jdev


2 Answers

According to Apple's article: About the Password AutoFill Workflow

For iOS apps, the system always sends a textDidChangeNotification notification when a view has been modified. It also calls one of the delegate methods of the view—but the exact method depends on the view’s type:

UITextField: The system calls your UITextFieldDelegate object’s textField(_:shouldChangeCharactersIn:replacementString:) method.

UITextView: The system calls your UITextViewDelegate object’s textView(_:shouldChangeTextIn:replacementText:) method.

Custom View adopting the UITextInput protocol: The system calls the insertText(:) method or replace(:withText:) in the UIKeyInput protocol.

You can create a subclass of UITextField or UITextView and override insertText(:) method and replace(:withText:) method, it will be called when user tap quickbar.

like image 200
J.Hunter Avatar answered Oct 20 '25 15:10

J.Hunter


In my case, I found that when I got a text in Should change Charater I got two empty spaces, there I come to know that it is autofill characters, so according to it, I update my four text field one by one.

like image 27
Vijayvir Sing Pantlia Avatar answered Oct 20 '25 15:10

Vijayvir Sing Pantlia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!