'iOS How to Auto proceed OTP after OTP tapped which is shown on keyboard

I have implemented iOS auto OTP functionality with code

if #available(iOS 12.0, *) {
    textContentType = .oneTimeCode        
 } else {}

I'm receiving OTP in the text field on tap the keyboard and once I tapped on the keyboard I want OTP should be auto proceed or auto submit after 7s. If I manually enter OTP I don't have to Auto OTP to proceed.

and here OTP length is dynamic. how do I get tapped event with OTP string?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source