fjcaetano / ReCaptcha

[In]visible ReCaptcha v2 for iOS
http://blog.flaviocaetano.com/post/recaptcha-reaches-1-dot-0/
MIT License
267 stars 133 forks source link

How to display the captcha in a modal view controller? #113

Closed astr0-4 closed 1 year ago

astr0-4 commented 2 years ago

The way I would like to use this is to do the validation in the background, and then if the captcha needs to be displayed, present that webview in a modal view controller where the user can press back or cancel.

But it seems like we can only add the view as a subview to the current view? If I could just get notified when the captcha is ready to be displayed I think I could present a view controller with the captcha webview. This seems like a pretty common use case, maybe I am just setting up the recaptcha wrong?

fjcaetano commented 2 years ago

There's a limitation on WKWebView where it only executes the JS content when the view is part of the visible view hierarchy. That's why the library asks for a view during validation time.

If you want to present the webview on a modal, you could try removing it from the current superview and adding it to the view controller you will be presenting, but tbh, I have no idea if that will work or not.

If you decide to go on that route, let us know if it works.