Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-recaptcha-v2-enhanced

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-recaptcha-v2-enhanced

Implement Google recaptcha v2 in React Native (both Android an iOS)

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-recaptcha-v2-enhanced

Implement Google recaptcha v2 in React Native (both Android an iOS)

Add it to your project

  1. Insall package
  • Using NPM npm install react-native-recaptcha-v2-enhanced
  • Using Yarn yarn add react-native-recaptcha-v2-enhanced
  1. Import package import ConfirmGoogleCaptcha from 'react-native-recaptcha-v2-enhanced';

Dependencies

  1. react-native-modal

  2. react-native-webview

Usage

import React from 'react';
import ConfirmGoogleCaptcha from 'react-native-recaptcha-v2-enhanced';
const siteKey = 'you_site_key';
const baseUrl = 'base_url';
class App extends React.Component  {
    onMessage = event => {
         if (event && event.nativeEvent.data) {
            if (['cancel', 'error', 'expired'].includes(event.nativeEvent.data)) {
                this.captchaForm.hide();
                return;
            } else {
                console.log('Verified code from Google', event.nativeEvent.data);
                setTimeout(() => {
                    this.captchaForm.hide();
                    // do what ever you want here
                }, 1500);
            }
        }
    };
    render() {
        return (
            <View style={styles.container}>
                <ConfirmGoogleCaptcha
                    ref={_ref => this.captchaForm = _ref}
                    siteKey={siteKey}
                    baseUrl={baseUrl}
                    languageCode='en'
                    onMessage={this.onMessage}
                />
                <Button
                    onPress={() => {
                        this.captchaForm.show();
                    }}
                    title='Click'
                    style={{ width: 120, backgroundColor: 'darkviolet' }}
                    textColor='#fff'
                />
            </View>
        );
    }
}

Note

You can import GoogleReCaptcha from 'react-native-recaptcha-v2-enhanced/GoogleReCaptcha'; to customize UI by yourself

DEMO

iOS

iOS

Android

Android

Props

  • siteKey (String) - The site key of the Google Recaptcha.
  • baseUrl (String) The url domain defined on your Google Recaptcha.
  • onMessage (Function) - The callback function after received response, error of Google captcha or when user cancel
  • languageCode (String) - Language to be display of captcha form. Can be found at this link
  • cancelButtonText (String) - Title of cancel button.

MIT Licensed

Keywords

FAQs

Package last updated on 27 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc