recaptcha: Google recaptcha doesn't work with cordova projects
since cordova projects don’t contain domain name the recaptcha throws
ERROR for site owner invalid domain for site key
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 9
- Comments: 22 (1 by maintainers)
For any still looking for the answer to this question, @jamescodesthings has a note in the documentation for cordova-plugin-recaptcha:
This addition got reCaptcha working for me in iOS. (reCaptcha was working out of the box on Android)
please see https://stackoverflow.com/questions/41518787/recaptcha-integration-with-ionic-hybrid-app/45364099#45364099
Hello @vicjohnson1213, I’m using Cordova too, have disabled the domain validation, still, getting the error
Error for site owner. Invalid domain for site key
, tried this<allow-navigation href="https://www.google.com/recaptcha/*" />
(however didn’t install the plugin) As discussed/mentioned in various forums since Cordova doesn’t contain a domain name, all the files are accessed using file://) Any suggestions/help, please!No worries, it’s a mixture of plain JS and Angular 1, but I kept to a fairly plain plugin format so that this wouldn’t be too big a problem when I chuck it in an NG 2+ project.
Bear with me, it’s been a little while since I did this in NG 2+.
In theory you can just use the plain JS version without too much hassle. You could create a service that then has access to the window object. From SO, something like:
Then just use the plain js from window:
In practice it depends a little on what your template is, do you have a public copy or an idea of how you’re currently working? I could help fudge it on in.
@jamescodesthings very thanks! your plugin is for Angular 1, right? I need this functionality for Angular 2 or higher. I don’t know how to use your plugin in my template.