Flutter
Only supports Android and iOS
Only supports Android and iOS
Add trustdevice_pro_plugin to pubspec.yaml of your project.
dependencies:
flutter:
sdk: flutter
...
trustdevice_pro_plugin: ^1.4.9Android: In the build.gradle of the application module, declare SDK package dependencies.
dependencies {
...
implementation 'com.trustdecision.android:apisign:1.1.3'
}iOS: Install(CocoaPods)
pod 'TrustDecisionAPISign', '1.1.1' to the corresponding target in the Podfile.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).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");
}
}
}If Android requires using ProGuard for obfuscation packaging, please add the following code to the ProGuard configuration file:
-keep class com.trustdecision.**{*;}