Geetest binding for react-native
For npm:
$ npm install --save react-native-geetest
For Yarn:
$ yarn add react-native-geetest
-
Right click on Libraries, select Add files to "…" and select
node_modules/react-native-geetest/RNGeetest.xcodeproj
-
Select your project and under Build Phases -> Link Binary With Libraries, press the + and select
libRNGeetest.a
$ react-native link
Add to android/settings.gradle
:
include ':geetest-sdk'
project(':geetest-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geetest/android/gtsdk/sdk')
include ':react-native-geetest'
project(':react-native-geetest').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-geetest/android')
Add the compile project line to android/app/build.gradle
(inside dependencies
):
dependencies {
// ... other content ...
compile project(':react-native-geetest')
}
Inside MainApplication.java
(normally somewhere here android/app/src/main/java/com//MainApplication.java)
add import import com.riskstorm.geetest.GeetestPackage;
and new GeetestPackage()
like in the example below
import com.riskstorm.geetest.GeetestPackage;
/* ... other content ... */
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new GeetestPackage()
);
}
import Geetest from 'react-native-geetest'
Geetest.setChallengeURL('Your challenger URL');
Geetest.setValidateURL('Your validate URL');
Geetest.request().then(() => {
alert('success');
}).catch(() => {
alert('failure');
});
Also you can listen to GeetestValidationFinished
event using DeviceEventEmitter
,
please view details in the Example project.
MIT