Implement recaptcha in an Ionic app

Asked

Viewed 588 times

0

I tried to use all the plugins I found to check (captcha) within my application. I am using the Ionic framework. I wonder if there is a plugin that works inside the html code in this case.

Some of which I tried to implement used the tag and I received an error from the console warning that this tag did not exist, even including everything the documentation asked for.

1 answer

2

Assuming this is your question:

I wonder if there is a plugin that works inside the html code in this case.

Use the component plugin ng-recaptcha for Angular 2+. Works perfectly on Ionic.

Add the module to your file app.module.ts (or similar):

import { RecaptchaModule } from 'ng-recaptcha';
import { BrowserModule }  from '@angular/platform-browser';
import { MyApp } from './app.component.ts';

@NgModule({
  bootstrap: [MyApp],
  declarations: [MyApp],
  imports: [
    BrowserModule,
    RecaptchaModule.forRoot(), //importante
  ],
})
export class MyAppModule { }

And then, in your html templates, state it as follows:

import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: '<re-captcha (onResolve)="resolved($event)" siteKey="CHAVE_DO_SEU_SITE"></re-captcha>',
}) 
export class MyApp {
  onResolve(captcha : string) {
    console.log(`Token captcha ${captcha}:`);
  }
}

Where CHAVE_DO_SEU_SITE is obtained through the reCAPTCHA Google website.

  • While this link may answer the question, it is best to include the essential parts of the answer here and provide the link for reference. Replies per link only can be invalidated if the page with the link is changed. - Of Revision

  • @Stormwind added due implementation to assist the requester.

  • Good answer, it seems much more complete =)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.