Socket
Socket
Sign inDemoInstall

react-native-google-recaptcha-v2

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-google-recaptcha-v2

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


Version published
Maintainers
1
Created

Readme

Source

react-native-google-recaptcha-v2

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

Thanks to https://github.com/aaronisme/rn-recaptcha

Add it to your project

  1. Run npm install react-native-google-recaptcha-v2 or yarn add react-native-google-recaptcha-v2
  2. import ConfirmGoogleCaptcha from 'react-native-google-recaptcha-v2';

Usage

import React from 'react';
import ConfirmGoogleCaptcha from 'react-native-google-recaptcha-v2';
const siteKey = 'you_site_key';
const baseUrl = 'base_url';
class App extends React.Component  {
    onMessage = event => {
        if (event && event.nativeEvent.data) {
            console.log('Verified code from Google',event.nativeEvent.data);
            if (event.nativeEvent.data === 'cancel') {
                this.captchaForm.hide();
                return;
            }
        }
        let timer = setTimeout(() => {
            this.captchaForm.hide();
            clearTimeout(timer);
        }, 1500);
    };
    render() {
        return (
            <View style={styles.container}>
                <ConfirmGoogleCaptcha
                    ref={_ref => this.captchaForm = _ref}
                    siteKey={siteKey}
                    baseUrl={baseUrl}
                    languageCode='en'
                />
                <Button
                    onPress={() => {
                        this.captchaForm.show();
                    }}
                    title='Click'
                    style={{ width: 120, backgroundColor: 'darkviolet' }}
                    textColor='#fff'
                />
            </View>
        );
    }
}
DEMO

iOS 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

MIT Licensed

Keywords

FAQs

Last updated on 15 Aug 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc