Only supports Android and iOS
Requirements
Environment
| Android | iOS | |
|---|---|---|
| Supported System Versions | Android 5.0 and above | iOS 9.0 and above |
| Supported Architectures | armeabi-v7a, arm64-v8a, x86 | armv7,arm64,x86_64 |
Integration
Installation
Adding Plugin
Execute the following command in the root directory of your React Native project:
npm install --save react-native-trustdeviceAdding Dependencies
Android: In the build.gradle of the application module, declare SDK package dependencies.
dependencies {
...
implementation 'com.trustdecision.android:apisign:1.1.3'
}iOS: Install(CocoaPods)
- Add
pod 'TrustDecisionAPISign', '1.1.1'to the corresponding target in the Podfile. - Execute the
pod install --repo-updatecommand in the folder containing the Podfile (For M1-series Mac computers, execute the commandarch -x86_64 pod install --repo-update).
Best Practices
Invoke the plugin's sign method at the actual business node to sign the URL that requires signing.
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
*/
import React, { useState } from 'react';
import {
StyleSheet,
Text,
View,
Button,
} from 'react-native';
// import the plugin
import { NativeModules } from 'react-native';
const TrustDevice = NativeModules.TrustDevice;
function App(): JSX.Element {
async function pathSign() {
try {
// the url that requires signing
const path = "dev/v2"
const signResult = await TrustDevice.sign(path);
if (signResult.code == 0) {
// Signing successful. You can now proceed with the business logic using the sign result.
const sign = signResult.sign;
// todo
} else {
// signing failed
console.log('Signing failed:', signResult.msg)
}
} catch (e) {
// signing error
console.log('Signing error:', e)
}
}
return (
<View style={styles.container}>
</View>
);
};
export default App;Status Code
| Code | Description | Action |
|---|---|---|
| 0 | Success | / |
| 2000 | The path parameter is null | Please set the path parameter |
| 22xx | Internal error | Please contact technical support |
| 30xx | Internal error | Please contact technical support |
| 4001 | Failed to call the .so file, possibly because the SDK-dependent .so file is missing | Please check if the architecture used by the current device is configured in the project |
| 4002 | Failed to call the SDK method | Please verify if the apisign module has been integrated into the project |
Additional Notes
Obfuscation Packaging
If Android requires using ProGuard for obfuscation packaging, please add the following code to the ProGuard configuration file:
-keep class com.trustdecision.**{*;}