Flutter

Only supports Android and iOS

Requirements

Environment

AndroidiOS
Supported System VersionsAndroid 5.0 and aboveiOS 9.0 and above
Supported Architecturesarmeabi-v7a, arm64-v8a, x86armv7,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.9

Adding 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-update command in the folder containing the Podfile (For M1-series Mac computers, execute the command arch -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

CodeDescriptionAction
0Success/
2000The path parameter is nullPlease set the path parameter
22xxInternal errorPlease contact technical support
30xxInternal errorPlease contact technical support
4001Failed to call the .so file, possibly because the SDK-dependent .so file is missingPlease check if the architecture used by the current device is configured in the project
4002Failed to call the SDK methodPlease 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.**{*;}