# react-native-geetest-sensebot [GEETEST极验行为验证](https://docs.geetest.com/install/overview/start/) [![npm version](https://badge.fury.io/js/%40yyyyu%2Freact-native-geetest-sensebot.svg)](https://www.npmjs.com/package/@yyyyu/react-native-geetest-sensebot) **SDK Version** iOS: v0.11.7_20190314 Android: v4.0.7_20190311 **测试环境** Xcode 10.2.1 react-native 0.59.5 ## Getting Started ```bash yarn add @yyyyu/react-native-geetest-sensebot # or npm i @yyyyu/react-native-geetest-sensebot --save ``` ```bash react-native link @yyyyu/react-native-geetest-sensebot ``` ### iOS 不使用 CocoaPods 在 Linked Frameworks and Libraries 中添加 node_modules/@yyyyu/react-native-geetest-sensebot/ios/SDK/GT3Captcha.framework ![add framework](doc/images/ios-add-framework.png) ### Android 在 AndroidManifest.xml 文件中添加权限 ```xml // ... ``` ## Example ```javascript import React, { Component } from 'react' import { View, Button } from 'react-native' import * as RNGeetestSensebot from '@yyyyu/react-native-geetest-sensebot' export default class App extends Component { geetest = async () => { let api1Result try { const api1Response = await fetch('http://www.geetest.com/demo/gt/register-test') api1Result = await api1Response.json() } catch (e) { return console.log('API1 request failed, message: %s.', e.message) } let geetestResult try { geetestResult = await RNGeetestSensebot.start({ api1Result, // optional default false debug: true, // optional default 10s loadTimeout: 10000, // optional default 10s reqTimeout: 10000, // optional default system lang: RNGeetestSensebot.Lang.System, // optional default false enableBackgroundCancel: true, // optional default transparent backgroundColorIOS: 'red', // optional default none backgroundBlurEffectIOS: RNGeetestSensebot.BackgroundBlurEffectIOS.Regular, // optional onEvent: (code, data) => { if (code === RNGeetestSensebot.Events.FAILED) { console.log('Validate failed, reason: %s', data[0]) } else { console.log(RNGeetestSensebot.Events[code], data) } } }) } catch (e) { return console.log('Error, code: %d, message: %s.', e.code, e.message) } let api2Result try { const api2Response = await fetch('http://www.geetest.com/demo/gt/validate-test', { method: 'POST', headers: { 'Content-Type': 'application/json;charset=UTF-8' }, body: JSON.stringify(geetestResult) }) api2Result = await api2Response.json() } catch (e) { return console.log('API2 request failed, message: %s.', e.message) } console.log('Validate result: %o.', api2Result) } render() { return (