ReCaptcha
public class ReCaptcha
extension ReCaptcha: ReactiveCompatible
-
The JS API endpoint to be loaded onto the HTML file.
See moreDeclaration
Swift
public enum Endpoint -
Initializes a ReCaptcha object
Both
apiKeyandbaseURLmay be nil, in which case the lib will look for entries ofReCaptchaKeyandReCaptchaDomain, respectively, in the project’s Info.plistA key may be aquired here: https://www.google.com/recaptcha/admin#list
Throws
ReCaptchaError.htmlLoadError: if is unable to load the HTML embedded in the bundle.Throws
ReCaptchaError.apiKeyNotFound: if anapiKeyis not provided and can’t find one in the project’s Info.plist.Throws
ReCaptchaError.baseURLNotFound: if abaseURLis not provided and can’t find one in the project’s Info.plist.Throws
Rethrows any exceptions thrown byString(contentsOfFile:)Declaration
Swift
public convenience init( apiKey: String? = nil, baseURL: URL? = nil, endpoint: Endpoint = .default, locale: Locale? = nil ) throwsParameters
apiKeyThe API key sent to the ReCaptcha init
baseURLThe base URL sent to the ReCaptcha init
endpointThe ReCaptcha endpoint to be used.
localeA locale value to translate ReCaptcha into a different language
-
Starts the challenge validation
Declaration
Swift
public func validate(on view: UIView, resetOnError: Bool = true, completion: @escaping (ReCaptchaResult) -> Void)Parameters
viewThe view that should present the webview.
resetOnErrorIf ReCaptcha should be reset if it errors. Defaults to
true.completionA closure that receives a ReCaptchaResult which may contain a valid result token.
-
Stops the execution of the webview
Declaration
Swift
public func stop() -
Provides a closure to configure the webview for presentation if necessary.
If presentation is required, the webview will already be a subview of
presenterViewif one is provided. Otherwise it might need to be added in a view currently visible.Declaration
Swift
public func configureWebView(_ configure: @escaping (WKWebView) -> Void)Parameters
configureA closure that receives an instance of
WKWebViewfor configuration. -
Resets the ReCaptcha.
The reset is achieved by calling
grecaptcha.reset()on the JS API.Declaration
Swift
public func reset() -
Provides a closure to be notified when the webview finishes loading JS resources.
The closure may be called multiple times since the resources may also be loaded multiple times in case of error or reset. This may also be immediately called if the resources have already finished loading when you set the closure.
Declaration
Swift
public func didFinishLoading(_ closure: (() -> Void)?)Parameters
closureA closure that is called when the JS bundle finishes loading.
-
Forces the challenge widget to be explicitly displayed.
Declaration
Swift
public var forceVisibleChallenge: Bool { get set } -
Allows validation stubbing for testing
When this property is set to
true, every call tovalidate()will immediately be resolved with.token("").Use only when testing your application.
Declaration
Swift
public var shouldSkipForTests: Bool { get set }
View on GitHub
ReCaptcha Class Reference