Code Monkey home page Code Monkey logo

recaptcha's Introduction

ReCaptcha

Build Status codecov PRs welcome Carthage compatible Version License Platform


Add Google's Invisible ReCaptcha v2 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 ReCaptcha v2 Invisible keys! Make sure to check the reCAPTCHA v2 Invisible badge option when creating your API Key.

ReCaptcha v2 invisible key example

You won't be able to use a ReCaptcha v3 key because it requires server-side validation. On v3, all challenges succeed into a token which is then validated in the server for a score. For this reason, a frontend app can't know on its own wether or not a user is valid since the challenge will always result in a valid token.

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

The reCAPTCHA keys can be specified as Info.plist keys or can be passed as parameters when instantiating ReCaptcha().

For the Info.plist configuration, add ReCaptchaKey and ReCaptchaDomain (with a protocol ex. http:// or https://) 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())
    }
}

If instead you prefer to keep the information out of the Info.plist, you can use:

let recaptcha = try? ReCaptcha(
    apiKey: "YOUR_RECAPTCHA_KEY", 
    baseURL: URL(string: "YOUR_RECAPTCHA_DOMAIN")!
)

...

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!

License

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

recaptcha's People

Contributors

dependabot[bot] avatar fjcaetano avatar light-cloud avatar manderson420 avatar marcelofabri avatar maxxx777 avatar yatatsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

recaptcha's Issues

Validate method does not work

Hello
I am using ReCaptcha v1.3.1 and my validate calling has no effect.

Steps to reproduce:

  1. In didLoad I create my ReCaptcha instance in Controller
  2. Call validate method
  3. Don't see a WebView widget with google recaptcha quiz

Also I noticed that if I comment this if statement it works properly. With this modification I see Recaptcha widget on the screen and also get a response token in success callback.
So debug tells me that didFinishLoading of ReCaptchaWebViewManager instance equals false and it returns immediately from the execute method.

Could you help me with this?

Thank a lot for lib.

Support for Swift 4.1

I've got an error of /Carthage/Build/iOS/ReCaptcha.framework/ReCaptcha compiled with older version of Swift language (4.0) than previous files (unknown ABI version 0x06) after intergrating this repo into my project with Carthage.

Would you please rebuild it and support this new version of Swift? Thanks in advance.

Update code for Swift 4

Hi guy,
I'm very interested in your work and want to use this for reCaptcha in my app. But there's too much error and obsoleted when running it with Xcode 9 and Swift 4.
I hope you can modify this to work with Swift 4. In that case, I'm very appreciated.
Thank you.

White page on offline validation

Hi,
I'd like to ask if it is possible to remove recaptcha web view even if the validation does not return a token.
In my particular case, before pressing 'verify' button I turned off my connectivity. The result is a white screen which is impossible to remove.

Thanks for the support,

Andrea

Does nothing happend

I have just test with example but seems to not work. it's loading after press Validate button and I wait a long time but nothing happen. Please check

Consider changing the api's url

For some reasons, all google.com domains are blocked in China. However, Google has just set up a domain called recaptcha.net and users in China can access through Google's server in Beijing.
So I suggest that you may change the url for people in China to access the service.
The url is https://www.recaptcha.net/recaptcha/api.js, (its certificate is issued by Google Internet Authority, so it is REAL)

is it legal

I have question, if this recapacha for ios legal?

As Apple terms and google terms ?

Webview does not disappear after success in UITableView

The recaptcha does not disappear when triggered from a button inside a UITableViewCell of a UITableView after success. It blocks the whole view totally. The result callback is called successfully.

The code to setup the recaptcha is almost the same as the one provided in the readme. I only change the CGRect part to move it lower to prevent it from blocked by the UINavigationBar.

recaptcha?.configureWebView { [weak self] webview in
    webview.frame = CGRect(x: 0, y: 40, width: self?.view.bounds.width ?? 0, height: self?.view.bounds.height ?? 0)
}

Maybe add a method to manually hide the view?

Screenshots:

simulator screen shot - iphone xr - 2018-09-22 at 19 27 35
simulator screen shot - iphone xr - 2018-09-22 at 19 27 47

No callback from ReCaptcha

Hi,
Currently we are using this library for Google ReCaptcha in apps, for now in development state.
While this library was integrated for long time and just now ( like week ago ) we started to have issues with this library.
I thought that this was fault of our code / configuration, but after debugging i found that in some cases user is stuck on sign in / sign up because of no response from ReCaptcha library.

our "sign up" flow:

  • type credentials
  • get recaptcha token
  • send recaptcha token along with credentials to API

To Reproduce

  • try to use wrong password to be able to invoke captcha multiple times
  • repeat until you get following log from webview:

#CAPTCHA LOG:
"["log": did load]"
"["log": executing]"
"["log": resetting]"

  • then completion block will not be called

Bug description

Since there is no completion block, app will wait for ReCaptcha result infinitely

Expected behavior

Library always respond with callback ( either error / token / challange )

Logs

responses from webview ( ReCaptchaDecoder::handle )

 "[\"log\": did load]"
 "[\"log\": executing]"
 "[\"log\": resetting]"

Additional context

I noticed that this issue more often occurs on real devices rather than on simulators
device i used for debugging: iPhone 7 with iOS 12.1.4

I also tried to find documentation for ReCaptcha and the things you've implemented, but i couldn't find them. Could you share some links in response?
(this official link is not sufficient for me, there is no information about statuses)

WKWebView content is not centered

When the WKWebView is loaded, the content of the webView is aligned left.

screen shot 2018-05-07 at 16 38 07

After Clicking anything that would refresh content (for example circled "i" icon with info), it will center itself.

screen shot 2018-05-07 at 16 38 27

Any ideas how to center it at the begining?

I think it loads content before the webView have bounds, and after getting the new bounds, the content doesn't reposition itself (untill "i" icon is tapped).

Webview content broken on iPhone X

The webview content breaks if rendered below 43px from the top of the iPhone X. This not related to the webview's width and height. The pictures attached shows reCaptcha webview inside a container view located at [0, 43], which looks fine, and the broken one located at [0, 44].

The weird part is that this is reproducible only on a real iPhone X device. I've tried other iPhones/iPad devices and simulators, including iPhone X simulator, both running 11.2.6 and 11.3 beta 3 and this issue only happens on a real iPhone X.

I guess it's somehow related to the webview adjusting the content inset. But disabling this feature doesn't fix it.

img_0861
img_0862

Also, configureWebView gets called many times, even after challenge has finished. And it also gets called many minutes after that.

Install lib

Hi,
How can I import ReCaptcha trough static way?
Is there any Objective C version of library?

Thanks for the support

Callbacks

Shouldn't both endpoints include: ?onload=onloadCallback&render=explicit?

case .default: return "https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit"
case .alternate: return "https://www.recaptcha.net/recaptcha/api.js"

Captcha not appear at all

Bug description

I have implemented reCaptcha as shown on readme and it doesn't appear at all. in console logs, I see did load, executing resetting, but nothing appears. I have created recaptcha v2 Invisible type.

Update: While I am checking reset to false. It's started to enter inside Clojure, but falling with error unexpected

Expected behavior

webview with captcha should be opened

Logs

[JS LOG]: did load
[JS LOG]: executing
[JS LOG]: resetting

Only 1 Call every 3-5 minutes

During The implementation, i found a issue and didn't know if was an error in API or just my implementation that was incorrect.

I'm defining the webView in This Function

func setupCaptcha(){
        self.recaptcha.configureWebView { [weak self] webview in
            webview.frame = CGRect(x: 5, y: 0, width: (self?.view.bounds.width)!, height: (self?.view.bounds.height)!)
        }
}

And Call that function in a TouchUpInside event of a Button called Consultar.

@IBAction func onClickConsultar(_ sender: UIButton) {
        self.setupCaptcha()
        validator.validate(self)
}

All of this is done before the call to ReCaptcha.validate function from the API(that is called in the callback method for this function validator.validate)

override func validationSuccessful() {
        recaptcha.validate(on: self.view, resetOnError: false) { [weak self] (result: ReCaptchaResult) in
            self?.prosseguir(renav: (self?.txtRenavam.text!)!, placa: (self?.txtPlaca.text!)!)
        }
 }

And finally, after the return of the ReCaptcha.validate and execution of the above method, i call the ReCaptcha.stop method before transit to the next View Controller.

But, being on the next controller and returning to the previous controller where the button is located, and try to click it again, with the intention of activating again the ReCaptcha.validate method from the API, i only received a message in LOG that says something like : Executing(and don't procede to callback function). After receive this message every time i clicked the button after returning to the controller where it is located, i tried to clicking after a few minutes to see if it would work, and it worked.

But, 1 validation of ReCaptcha every 3 to 5 minutes is very infeasible.

i do not know if it was my mistake or the API that does not support this or if is correct , can you help me ?

Invisible ReCaptcha always show images

Hello, I have some issues with invisible reCaptcha. My keys are in place and everything's working as expected, but it always shows the images instead of passing reCaptcha silently. What could be wrong?

I set my preferences to use Invisible one

I also tried to set the reCaptcha?.forceVisibleChallenge tofalse but it didn't help. Is there an issue with my IP address? I also tried to use a different one, but it didn't help either

Intermittent WTF::HashTable Bug

Bug description

We've noticed the following intermittent crash for a small number of our users since starting to use the ReCaptcha library in our app:
Screenshot 2019-07-08 at 09 51 38

We haven't been able to reproduce this on either our own devices or simulators, however it still appears on a consistent basis. It doesn't affect everyone, but we do get a couple of reports a week (via Firebase Crashlytics). It appears to be related to the use of WebKit, but other than that we are not sure what is causing this or how to fix it, other than that it appears to be related to this library.

Has anyone else come across this, and found a way to fix or avoid? We're pretty stumped as to what's going on.

Bypasssing captcha in UITests

In case where we want to use ReCaptcha in app, then test it with UITests, i think there was no way to "stub" capatcha, to complete for instance sign in flow then make something else in app.

I created a PR for that #50

What do you think about this idea? i'm open to changes

JavaScript Exception

I got this exception most of the times when I run the app on device, and sometimes on simulator. I can not find the root cause. Any idea?

Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=11, WKJavaScriptExceptionMessage=TypeError: Argument 1 ('target') to MutationObserver.observe must be an instance of Node, WKJavaScriptExceptionSourceURL=http://localhost/, NSLocalizedDescription=A JavaScript exception occurred, WKJavaScriptExceptionColumnNumber=13}))

Force Recaptcha to show from Carthage library

Bug description

First, thanks for the library, I'm finding it quite useful. However, there's a little flaw in that I'm unable to trigger forceVisibleChallenge since I'm using it as a carthage dependency.

Since Carthage by default compiles code in release mode, this code will not be available:

#if DEBUG
    /// Forces the challenge widget to be explicitly displayed.
    public var forceVisibleChallenge: Bool {
        get { return manager.forceVisibleChallenge }
        set { manager.forceVisibleChallenge = newValue }
    }

    /**
     Allows validation stubbing for testing
     When this property is set to `true`, every call to `validate()` will immediately be resolved with `.token("")`.
     
     Use only when testing your application.
    */
    public var shouldSkipForTests: Bool {
        get { return manager.shouldSkipForTests }
        set { manager.shouldSkipForTests = newValue }
    }
#endif
}

Is it possible to replace this behaviour with a bool flag (enableDebug) on init? e.g. as referred to in https://holko.pl/2018/09/24/compilation-directives-in-libraries/

To Reproduce

  1. Use Recaptcha library from Carthage.
  2. Try to use forceVisibleChallenge

Expected behavior

forceVisibleChallenge should work irrespective of whether it's from Carthage or not.

Use Single on rx.validate

Since the rx.validate method only returns one result, it would be better if it used the Single factory instead of a generic Observable factory.

[BUG] UI API called on a background thread

[BUG]
Hello,
I'm facing a crash when i initialize my Recaptcha.
fileprivate let recaptcha = try! ReCaptcha()

After something like 0.5 secondes, the app crash with a Main Thread Checker: UI API called on a background thread.

I've no request with ui modification in my viewDidLoad. Maybe you should check if you've not forget to force an UI API call in the main thread on your side ?

I will investigate it too.

Kind Regards

HELP WANTED - Contributors needed

Due to personal and professional issues, I'm no longer being able to give the necessary attention this project requires.

If you're using this library in a production app or have regular contact with it, your help triaging issues and responding to the community would be much appreciated. If you want to be hands-on with the code and help with bugfixes and new features, even better! All help is welcome.

As of this moment, this project hasn't been abandoned. It may take some time to respond to issues or get into development, but I'm still here.

Javascript Exception

This is still broken on version 1.0.1 for us. iOS 11.0 iPhone 6 device. This ONLY seems to be an issue on iOS 11.0 so far; not on any minor/major revisions after it. We are getting the following error from the ReCaptcha library: Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={WKJavaScriptExceptionLineNumber=16, WKJavaScriptExceptionMessage=TypeError: undefined is not an object (evaluating 'document.getElementsByTagName("div")[4].outerHTML = ""'), WKJavaScriptExceptionColumnNumber=44, WKJavaScriptExceptionSourceURL=https://ourdomain.com/, NSLocalizedDescription=A JavaScript exception occurred}

The curious thing is that this causes an exception every other time we kick off the ReCaptcha webview flow. The following time we get a successful result. Any ideas?

Update: As mentioned from @fjcaetano: that seems to be a different error. It appears to have been introduced with 78fa352, since it fails on getElementsByTagName("div")[4].

Could you open a new issue so we can address this?

Also, as a workaround, could you try removing that line from recaptcha.html to check if the issue stops?

Javascript exception occurred

ReCaptchaDomain is http://localhost/, but at validate the webview is interrupted with a Javascript exception expecting ReCaptchaDomain in the html?

Unexpected Error: Error Domain=WKErrorDomain Code=4 \"A JavaScript exception occurred\"
UserInfo={WKJavaScriptExceptionLineNumber=24, WKJavaScriptExceptionMessage=TypeError:
Argument 1 (\'target\') to MutationObserver.observe must be an instance of Node,
WKJavaScriptExceptionColumnNumber=13, WKJavaScriptExceptionSourceURL=http://localhost/,
NSLocalizedDescription=A JavaScript exception occurred}"

hiding recaptcha webview after completing the challenge?

I am having some problems figuring out how can I hide the webview after displaying the challenge, my code is

recaptcha.validate(on: view) { [weak self] result in
       //some logic here (no recaptcha api calls)
}

after completing the challenge, the puzzle itself disappears, but a blank white screen is all that's left, do I have to hide the webview somehow after completing the challenge?

thanks for the great effort you put in this library

Support recaptcha `reset`

A reset method has been released for the JS API.

This may enable us to stop having to allocate a new instance of ReCaptcha whenever an error occur.

Intermittent Error

I get two different outcomes, seemingly at random, at times all go as planned, but other times i get the error Unexpected Error: Error Domain=WKErrorDomain Code=4 "Ocorreu uma exceção JavaScript" UserInfo={WKJavaScriptExceptionLineNumber=24, WKJavaScriptExceptionMessage=TypeError: Argument 1 ('target') to MutationObserver.observe must be an instance of Node, WKJavaScriptExceptionColumnNumber=13, WKJavaScriptExceptionSourceURL=http://com.btg.pactual.digital.mobile/, NSLocalizedDescription=Ocorreu uma exceção JavaScript}

tested on iPhone 6 and 6S, both on iOS 12.1.4, using the latest pod version

ReCaptcha webview stuck at loading

Bug description

When trying to integrate in my app, after setting up and invoking validate, the 'execute' never gets executed because in ReCaptchaWebViewManager.execute(), the "didFinishLoading" variable is always false, so the execute command gets skipped.

I tried the example project to see if I could repro there. I am seeing something similar with the example project, with a caveat. When I load example project, the first time I hit 'validate' it appears to work and I see the Captcha string. However if I hit 'validate' again, the validate never completes. The validate button remains disabled and I see the following statement in the app log.

"[JS LOG]: executing"

If I kill the example app and start it again, it will again work the first time, but will consistently hang on the second attempt.

Expected behavior

I would expect the example app 'validate' to work on the second try. I would also expect the integration in my app to load correctly and get to the execute command.

Additional context

I am looking at this library because our current invisible recaptcha v2 has broken recently. When we try to invoke invisible captcha, our implementation has recently started showing a 'Please upgrade to supported browser' message (using either WKWebView or UIWebView to run the javascript). Looking at this thread https://news.ycombinator.com/item?id=18332549 it appears that there were changes to all versions of ReCaptcha lately. I had assumed that this library would have the same problem we were facing, but my implementation isn't as robust as this libraries. I'm curious if the problem I am seeing with the library/example project are related to this unsupported browser issue.

Retire Result dependency

Results enums are too simple to require a dependency.

Retire this framework and implement it on the project.

configureWebView is called multiple times for no apparent reason (always after reload of a content of the webview)

ViewController#1 with captcha

        reCaptcha.rx.validate(on: view).subscribe(onNext: { [weak self] (token: String) in
            guard let `self` = self else { return }
            self.viewModel.captchaToken = token
            self.dismiss(animated: true)
        }) >>> bag

        reCaptcha.configureWebView { [weak self] webView in
            guard let `self` = self else { return }
            if self.viewModel.captchaToken == nil {
                self.viewModel.openReCaptcha(source: self, webView: webView) //open new VC#2 modally
            }
        }

ViewController#2 with webView

    override func viewDidLoad() {
        super.viewDidLoad()
        setupWebView()
    }

    private func setupWebView() {
        webContainerView.addSubview(webView)
        webView.frame = webContainerView.bounds
        webView.scrollView.isScrollEnabled = false
    }

STR:

  1. Open VC#1
  2. Wait for configureWebView to trigger. It will open VC#2
  3. Don't fill ReCaptcha challange, just dismiss() this VC#2
  4. Wait for about 10 minutes with VC#1 on the screen (I tested it twice with stopwatch at it was 10 mintues +/- 10 seconds both times!)

Expected: Nothing happened
Result: After 10 idle minutes configureWebView closure is oppened again from case .showReCaptcha. It will open VC#2, but there will be now webView this time.

Additional problem:
This line is a workaround:

if self.viewModel.captchaToken == nil { 
    //code 
}

as configureWebView is triggered also right after validation closure is done...

also this code

// Ensures `configureWebView` won't get called multiple times in a short period
            DispatchQueue.main.debounce(interval: 1)

will work only if not debugging. When paused in debug, more than 1 second will pass and there will be more than one consecutive call (just not within one second).

WKErrorDomain Code=4

Hi,
I created a simple project, identical to your Example, in which I only setup recaptcha and call the validate function. The UI is made by an empty UIView
I have created API keys and My APIdomain is "localhost", XCode 9.4.
When I start the application the log which appears is :
[JS LOG]: did load
[JS LOG]: executing
[JS LOG]: resetting
[JS LOG]: executing
[JS LOG]: resetting
[JS LOG]: executing
[JS LOG]: resetting
[JS LOG]: executing
[JS LOG]: resetting
[JS LOG]: executing
[JS LOG]: resetting
[JS LOG]: executing
[JS LOG]: resetting
......

and the error is:

"Unexpected Error: Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo={NSLocalizedDescription=A JavaScript exception occurred}"

Is it a problem of the backend configuration? In this case how can I simulate the flow only from app side?

Thanks for the support

Change version of RxSwift dependency in podspec

Hello,
We are migrating our project from Swift 4.1 to Swift 4.2.
The project and all its dependencies (except ReCaptcha) are using RxSwift 4.4.0. The problem is ReCaptcha 1.4 can not use version 4.4.0 of RxSwift because of rx.dependency 'RxSwift', '~> 4.3.1'
May it be replaced with e.g. rx.dependency 'RxSwift', '~> 4.3'? (ReCaptcha has no conflicts with RxSwift 4.4.0)

Please let me know if I could make PR to update podspec file.

Endless cycle of executing/resetting

Hi,

I am trying to use ReCaptcha v1.2 and when calling validate, I get an endless loop of log statements:
[JS LOG]: resetting
[JS LOG]: executing
[JS LOG]: resetting
[JS LOG]: executing
etc etc

Any ideas?

WebView doesn't show up in the app

Hi, I have installed pod "ReCaptcha" and follow your usage description but when i run app and click a button, the Webview doesn't show up. This is my code, please give a look and tell me what is wrong. Thank you.

class ConfirmViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
    // Outlets
    @IBOutlet weak var btnReceivedPlace: UIButton!
    @IBOutlet weak var stackView: UIStackView!
    @IBOutlet weak var pickerReceivedPlace: UIPickerView!
    
    // Varibles
    var receivedPlacePosition: Int = 0
    fileprivate let recaptcha = try! ReCaptcha()
    fileprivate static let webViewTag = 123
    
    override func viewDidLoad() {
        super.viewDidLoad()
        pickerReceivedPlace.dataSource = self
        pickerReceivedPlace.delegate = self
        
        recaptcha.configureWebView { [weak self] webview in
            webview.frame = self?.view.bounds ?? CGRect.zero
            webview.tag = ConfirmViewController.webViewTag
        }
    }
    
    @available(iOS 2.0, *)
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }
    
    func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
        return receivedPlaceArr.count
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return receivedPlaceArr.count
    }
    
    func pickerView(_ pickerView: UIPickerView, viewForRow row: Int, forComponent component: Int, reusing view: UIView?) -> UIView {
        var label = view as! UILabel!
        
        if label == nil {
            label = UILabel()
        }
        let data = receivedPlaceArr[row]
        let title = NSAttributedString(string: data, attributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14.0, weight: UIFont.Weight.regular)])
        label?.attributedText = title
        label?.textAlignment = .center
        return label!
    }
    
    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
        btnReceivedPlace.setTitle(receivedPlaceArr[row], for: .normal)
        pickerReceivedPlace.isHidden = true
    }
    
    @IBAction func btnReceivedPlaceClick(_ sender: Any) {
        pickerReceivedPlace.isHidden = false
    }
    
    @IBAction func btnCaptchaClick(_ sender: Any) {
        print("btnCaptcha clicked")
        
        recaptcha.validate(on: view) { (result) in
            print(try! result.dematerialize())
        }
    }
    
    func saveInfo() -> Confirm {
        return Confirm(receivedPlaceId: "\(receivedPlacePosition)")
    }

I make a view like that and when clicking on I'm not robot image I will call validate.
screen shot 2017-07-13 at 4 33 57 pm

Visible challenge appearing to nearly 50% to our users.

Bug description

We are getting an unusually high amount of user seeing the visible challenge in iOS. In Android (enabled in all countries except China) the amount is about 4% (taking into consideration that their library is native), in web (enabled in all countries) we have about 30% but in iOS (enabled only in Turkey) that number goes up to nearly 50% of users seeing the visible challenge.

All that was taken from the Google recaptcha admin dashboard.

Is this behaviour expected? Is there any way we can bring down that number? All platforms started by being rolled out only in Turkey and then to other countries if the results were within our tolerance range.

To Reproduce

Steps to reproduce the behavior:

  1. Configure the library.
  2. Call the verify method.
  3. Half our users are seeng the visible challenge.

Expected behavior

A small amount of users see the visible challenge.

Additional context

Here are the graphs we are seeing in the admin dashboard:

Android:
image 2 - android - enabled in all countries except china

Web:
image 1 - web - enabled in all countries

iOS using this library:
image 3 - ios - was enabled in turkey only

Language support

Hi. Could you add forcing language?

All it takes is to add one parameter to endpoint call ("hl"). Maybe as an optional string associated value in the endpoint enum? I can fork and make a pull request if you want to :)

Alternate endpoint not working

When using the alternate endpoint, calling validate will result in nothing. Validate method is also not working. Nothing is logged.

It seems that js script provided by the alternate endpoint is different from that provided by the normal endpoint? Maybe a bug from Google?

documentation: keys and use-cases

Hi,
I don't understand the use-case.
Let's say an application is using this library before submitting something to a remote server.

  1. The "key" in this context would be the "public key" of the captcha. You confirm?
  2. Then the g-response-message (that this library take care of) is going to be submitted to the server which will use it's secret key to verify the captcha. Still right?
  3. In this context what means ReCaptchaDomain?
  4. Sample show recaptcha?.validate(), what means "validating" in this context?
  5. Sample use a webview.frame is it still compatible with native app' not relying on webview?

thx!

Validate doesn't respond if it's called second time

If I call the validate function for the second time it doesn't respond, the log only says
[JS LOG]: executing
and the completion is not called waiting forever.

The bug can be reproduce in the "Example" project also, tapping validate button first time works but not the second time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.