in Education by
I am trying to implement the reCaptcha function to my flutter app, but in the captcha registration I need to provide a domain which I don't have one for a mobile app. I have browsed several guides teaching how to implement reCaptcha into a mobile app, yet those guides registered their reCaptcha with package names but not domains. What is the correct way to implement reCaptcha in a flutter app, or any mobile app in 2020? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You can use this plugin, flutter_recaptcha. For the domain, I had the same issue. I first found that I needed to use the "I'm not a robot" checkbox option from here and I had to check the github repository to find this information, "!!! Remember to add this domain into the reCaptcha setting: recaptcha-flutter-plugin.firebaseapp.com," which explains it. I was lost for a bit after not seeing that on the main page, but now it makes sense. Hopefully it helps. Edit I noticed something after trying it out, that I'd like to mention. The plugin does not provide a captcha response for using to authenticate the user server-side, so it does not seem very useful as it is. However, it is a simple plugin, so it may be possible to use it as an example. The steps, I think, would be to create a webpage with the captcha. As with the plugin, use a webview to open the page, then capture the post output of the form and ip address of user submitting the form, using something like this, then send it to flutter and then submit your request with that information, and use the Google library to verify the captcha. Instructions I just finished implementing this and I found a good way that works. First, create an html page, like this: reCAPTCHA
function captchaCallback(response){ //console.log(response); if(typeof Captcha!=="undefined"){ Captcha.postMessage(response); } } Then, host that on your domain, say example.com/captcha. Then, create a flutter Widget, like this: import 'dart:async'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class Captcha extends StatefulWidget{ Function callback; Captcha(this.callback); @override State createState() { return CaptchaState(); } } class CaptchaState extends State{ WebViewController webViewController; @override initState(){ super.initState(); } @override Widget build(BuildContext context) { return Center( child: WebView( initialUrl: "https://example.com/captcha.html", javascriptMode: JavascriptMode.unrestricted, javascriptChannels: Set.from([ JavascriptChannel( name: 'Captcha', onMessageReceived: (JavascriptMessage message) { //This is where you receive message from //javascript code and handle in Flutter/Dart //like here, the message is just being printed //in Run/LogCat window of android studio //print(message.message); widget.callback(message.message); Navigator.of(context).pop(); }) ]), onWebViewCreated: (WebViewController w) { webViewController = w; }, ) ); } } Make sure you registered for a captcha key at https://www.google.com/recaptcha (click on "Admin Console" at the top-right). Then, you have the front-end built. To call a captcha, just run: Navigator.of(context).push( MaterialPageRoute( builder: (context){ return Captcha((String code)=>print("Code returned: "+code)); } ), ); You can use whatever callback you want to, like this: class GenericState extends State{ void methodWithCaptcha(String captchaCode){ // Do something with captchaCode } @override Widget build(BuildContext context) { return Center(child:FlatButton( child: Text("Click here!"), onPressed: (){ Navigator.of(context).push( MaterialPageRoute( builder: (context){ return Captcha(methodWithCaptcha); } ), ); } } } Server-side, you can follow the instructions here (I followed the sections "Direct Download" and "Usage"). I found that for the usage, I could simply use the code: $recaptcha = new \ReCaptcha\ReCaptcha($secret); $resp = $recaptcha->verify($gRecaptchaResponse, $remoteIp); if ($resp->isSuccess()) { // Verified! } else { $errors = $resp->getErrorCodes(); } Using setExpectedHostname, like in the example, was unnecessary. After that, everything works! I think this is currently the best way to implement Google reCaptcha V2 in flutter (for both iOS and Android).

Related questions

0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I'm new to flutter and can't resolve the issue. Your application could not be compiled, because its ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 15, 2022 in Education by JackTerrance
0 votes
    I'm working on a program that displays a list from an SQFlite table. The future for the snapshot ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 30, 2022 in Education by JackTerrance
0 votes
    I'm new to Flutter Redux, I got a problem and I have no idea how to deal with it at all! ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I need to build a pop up dialog box in my app. I am using Dialog class and wrapped it with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I am adding an background image to the Splash screen, but is not rendering the image. Sometime it load ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I have this operation EventModel data = EventModel(_nameEvent, _passEvent, _localEvent, _dateEventString); HashMap ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I'm getting Authorization failure when trying to display a map in a flutter project using the google maps ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Video does not capture in the right orientation when running the Camera Plugin example app on my iPhone X in Landscape. It works well ... .0+1 environment: sdk: ">=2.0.0-dev.68.0...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I do have a main application in Flutter using Hive as database, and I would like to incorporate another ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I have to put an input on the site from Excel file which I have done successfully. The only thing i got stuck ... as per the Excel file Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have to put an input on the site from Excel file which I have done successfully. The only thing i got stuck ... as per the Excel file Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I'm using the official Google Maps Flutter plugin to show maps and it works perfectly well but now I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 21, 2022 in Education by JackTerrance
0 votes
    I'm using flutter_map package and I need to draw path between 2 marker. I know map_view package provided ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    "masses": [ { "Sunday": [ { "mass_timing": "7.00 AM", "mass_place": "First Mass", " ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 6, 2022 in Education by JackTerrance
...