Go to file
Flávio Caetano 43d9ae7495 Enables chinese endpoint for JS API
fix #10
2017-10-17 12:47:15 -02:00
Example Enables chinese endpoint for JS API 2017-10-17 12:47:15 -02:00
ReCaptcha Enables chinese endpoint for JS API 2017-10-17 12:47:15 -02:00
.gitignore Documentation 2017-04-11 18:27:10 -03:00
.swift-version Fixing Travis-CI builds 2017-09-29 13:39:55 -03:00
.travis.yml Fixing iOS version on Travis matrix 2017-09-29 14:30:45 -03:00
CHANGELOG.md CHANGELOG 2017-04-13 17:21:45 -03:00
LICENSE Initial code 2017-04-11 15:00:44 -03:00
README.md Enables chinese endpoint for JS API 2017-10-17 12:47:15 -02:00
ReCaptcha.podspec Updating README 2017-04-18 15:35:55 -03:00
_Pods.xcodeproj Initial code 2017-04-11 15:00:44 -03:00
codecov.yml Fixing docs & codecov.yml 2017-04-17 10:43:14 -03:00
example.gif Adding gif to README 2017-04-18 15:54:02 -03:00
example2.gif Adding new example gif 2017-07-14 11:48:52 -04:00

README.md

ReCaptcha

Build Status Version License Platform codecov


Add Google's Invisible ReCaptcha to your project. This library automatically handles ReCaptcha's events and retrieves the validation token or notifies you to present the challenge if invisibility is not possible.

Example Gif 2 Example Gif

Warning ⚠️

Beware that this library only works for Invisible ReCaptcha keys! Make sure to check the Invisible reCAPTCHA option when creating your API Key

Installation

ReCaptcha is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "ReCaptcha"
# or
pod "ReCaptcha/RxSwift"

Usage

Simply add ReCaptchaKey and ReCaptchaDomain to your Info.plist and run:

let recaptcha = try? ReCaptcha()

override func viewDidLoad() {
    super.viewDidLoad()

    recaptcha?.configureWebView { [weak self] webview in
        webview.frame = self?.view.bounds ?? CGRect.zero
    }
}


func validate() {
    recaptcha?.validate(on: view) { [weak self] result in
        print(try? result.dematerialize())
    }
}

You can also install the reactive subpod and use it with RxSwift:

recaptcha.rx.validate(on: view)
    .map { try $0.dematerialize() }
    .subscribe(onNext: { (token: String) in
        // Do something
    })

Alternte endpoint

If your app has firewall limitations that may be blocking Google's API, the JS endpoint may be changed on initialization. It'll then point to https://www.recaptcha.net/recaptcha/api.js:

public enum Endpoint {
    case default, alternate
}

let recaptcha = try? ReCaptcha(endpoint: .alternate) // Defaults to `default` when unset

License

ReCaptcha is available under the MIT license. See the LICENSE file for more info.