BJOTPViewController icon indicating copy to clipboard operation
BJOTPViewController copied to clipboard

Resend Code option missing

Open jriosdev opened this issue 5 years ago • 2 comments

you did good work There is no resend code time please add that too

jriosdev avatar Nov 19 '20 12:11 jriosdev

@jriosdev Thank you.

In order to resend code, set footerTitle and then make the shouldFooterBehaveAsButton property true. On tapping the footer, the below delegate method will be called:

func didTap(footer button: UIButton, from viewController: BJOTPViewController) {
 
 /**
  * This delegate method will get called when the footer button at the bottom is tapped. Use this to resend one time code from the server.
  *
  * This method will only be called when the `shouldFooterBehaveAsButton` is `true`.
  *
  * - Parameter button: The button that's tapped.
  * - Parameter viewController: The otp view controller. Use this to show loaders, spinners, present any other view controllers on top etc..
  *
  * - Author: Badhan Ganesh
  */
  
 }

For the timer part, you could easily use an NSTimer object and then assign footerTitle a new string every second; the UI will be updated automatically upon assignment. I'm leaving this (timer) implementation to the devs who are using the view controller. 🙂 I think it is best when implemented by the ones who are using it based on their requirements.

Feel free to let me know if you face any other issue(s). Thanks again.

BadhanGanesh avatar Nov 20 '20 19:11 BadhanGanesh

UPDATE:

I'm adding the enhancement label and will surely consider implementing the feature in a future release. But for now, the resend timer can be easily added with a few lines of code.

BadhanGanesh avatar Nov 22 '20 11:11 BadhanGanesh