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
Add trustdevice_pro_plugin to pubspec.yaml of your project.
dependencies:
flutter:
sdk: flutter
...
trustdevice_pro_plugin: ^1.4.9Adding 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.
import 'package:trustdevice_pro_plugin/trustdevice_pro_plugin.dart';
class _MyAppState extends State<MyApp> {
final _trustdeviceProPlugin = TrustdeviceProPlugin();
@override
void initState() {
super.initState();
_pathSign("dev/v2?id=1");
}
Future<void> _pathSign(path) async {
try {
final resultData = await _trustdeviceProPlugin.sign(path);
final sign = resultData['sign'] as String? ?? '';
final msg = resultData['msg'] as String? ?? '';
final code = resultData['code'] as int;
if (code == 0) {
// Signing successful. You can now proceed with the business logic using the sign result.
} else {
// signing failed
print('Signing failed: $msg');
}
} catch (e) {
print("Signing error:$e");
}
}
}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 |
Additonal 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.**{*;}