Go to file
Maxim Tsvetkov 484ed94a9b Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' (#59)
* - Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' in podspec and podfile
- Update pods

* Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' in cartfile
2018-11-12 14:15:25 -02:00
.github/ISSUE_TEMPLATE Improve bug_report.md 2018-09-27 15:25:56 -03:00
Example Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' (#59) 2018-11-12 14:15:25 -02:00
ReCaptcha Feature: enable validation to be skipped for testing 2018-09-27 15:00:22 -03:00
ReCaptcha-Carthage Carthage support 2017-10-19 10:42:34 -02:00
ReCaptcha-Carthage.xcodeproj Updates to support Swift 4.2. (#52) 2018-09-26 15:26:52 -03:00
ReCaptcha_RxSwift Carthage support 2017-10-19 10:42:34 -02:00
fastlane Fix test devices on Fastfile 2018-09-27 15:29:48 -03:00
.gitignore Version Bump 2017-12-01 15:12:53 -02:00
.gitmodules Fix: Running Fastlane with a single device 2017-11-13 16:42:39 -02:00
.jazzy.yaml Adding jazzy config file 2018-09-06 16:14:53 -03:00
.swiftlint.yml Updating docs license year 2018-01-29 12:37:52 -02:00
.travis.yml Updates to support Swift 4.2. (#52) 2018-09-26 15:26:52 -03:00
CHANGELOG.md Version Bump (1.4) 2018-09-27 16:02:55 -03:00
Cartfile Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' (#59) 2018-11-12 14:15:25 -02:00
Cartfile.resolved Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' (#59) 2018-11-12 14:15:25 -02:00
Gemfile Updates to support Swift 4.2. (#52) 2018-09-26 15:26:52 -03:00
Gemfile.lock Updates to support Swift 4.2. (#52) 2018-09-26 15:26:52 -03:00
LICENSE Version Bump 2018-01-10 13:16:23 -02:00
README.md Readme: Help wanted 2018-06-14 15:31:48 -03:00
ReCaptcha.podspec Change Rx dependencies version from '~> 4.3.1' to '~> 4.3' (#59) 2018-11-12 14:15:25 -02:00
_Pods.xcodeproj Initial code 2017-04-11 15:00:44 -03:00
codecov.yml Fix: Codecov range 2017-11-13 16:43:09 -02: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
pre-push.sh Fix: Running Fastlane with a single device 2017-11-13 16:42:39 -02:00

README.md

ReCaptcha

Build Status Version License Platform codecov Carthage compatible


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 and Carthage. To install it, simply add the following line to your dependencies file:

Cocoapods

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

Carthage

github "fjcaetano/ReCaptcha"

Carthage will create two different frameworks named ReCaptcha and ReCaptcha_RxSwift, the latter containing the RxSwift extension for the ReCaptcha framework.

Usage

Simply add ReCaptchaKey and ReCaptchaDomain (with a protocol) 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: ReCaptchaResult) in
        print(try? result.dematerialize())
    }
}

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

recaptcha.rx.validate(on: view)
    .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

Help Wanted

Do you love ReCaptcha and work actively on apps that use it? We'd love if you could help us keep improving it! Feel free to message us or to start contributing right away!

Full Documentation

License

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