flutter_treezor_entrust_sdk_bridge
Requirement
For Android :
- Minimum android sdk version : 22
- Maximum android sdk version : 34
For IOS :
- Xcode 13.0.0 or later
Install
On main project
dependencies:
....
flutter:
sdk: flutter
flutter_treezor_entrust_sdk_bridge:
path: [pathToPluginFolder]/
launch the exemple app
flutter run
Main app integration requirement
Android
Follow Android Entrust Documentation https://doc.antelop-solutions.com/latest/wallet/sdk/android_integration.html
Ios
Follow Ios Entrust Documentation https://doc.antelop-solutions.com/latest/wallet/sdk/ios_integration.html
You can check the example app for some ios configuration
How to use the SDK
register
Future<void> connectSDK() async {
WalletManagerModule walletManagerModule = _flutterTreezorEntrustSdkBridgePlugin.getWalletManagerModule();
WalletManagerCallbacks walletManagerCallbacks = WalletManagerCallbacks(
onProvisioningRequired:() => {
onWalletManagerProvisioningRequired(walletManagerModule)
},
onCredentialsRequired:(reason, error) => {
onWalletManageronCredentialsRequired(reason, error, walletManagerModule)
},
onConnectionError:(error) => {
debugPrint("onConnectionError error: $error")
},
onConnectionSuccess:() => {
onWalletManagerOnConnectionSuccess()
}
);
await walletManagerModule.initialize(walletManagerCallbacks);
walletManagerModule.connect(null, null);
}
void onWalletManagerProvisioningRequired(WalletManagerModule walletManagerModule) async {
debugPrint("onProvisioningRequired");
String activationCode = await getWalletActivationCode();
debugPrint("onWalletManagerProvisioningRequired activationCode: $activationCode");
WalletProvisioningModule walletProvisioningModule = _flutterTreezorEntrustSdkBridgePlugin.getWalletProvisioningModule();
WalletProvisioningCallbacks walletProvisioningCallbacks = WalletProvisioningCallbacks(
onInitializationSuccess:() => {
debugPrint("onInitializationSuccess"),
walletProvisioningModule.checkEligibility(false)
},
onInitializationError:(error) => {
debugPrint("onInitializationError")
},
onPermissionNotGranted:(permissions) => {
debugPrint("onPermissionNotGranted")
},
onDeviceEligible:(fingerprintAllowed) => {
debugPrint("onDeviceEligible"),
walletProvisioningModule.launch(activationCode.substring(2))
},
onDeviceNotEligible:(reason, denialReference) => {
debugPrint("onDeviceNotEligible")
},
onCheckEligibilityError:(error) => {
debugPrint("onCheckEligibilityError")
},
onProvisioningPending:() => {
debugPrint("onProvisioningPending")
},
onProvisioningSuccess:() => {
debugPrint("onProvisioningSuccess"),
walletManagerModule.connect(null, null)
},
onProvisioningError:(error) => {
debugPrint("onProvisioningError")
}
);
await walletProvisioningModule.initialize(walletProvisioningCallbacks);
}
void onWalletManageronCredentialsRequired(String reason, AntelopError? error, WalletManagerModule walletManagerModule) async {
debugPrint("onCredentialsRequired reason : $reason error: $error");
switch (reason.toLowerCase()) {
case "notset":
walletManagerModule.connect(null, newPasscode);
break;
case "tobechanged":
walletManagerModule.connect(passcode, null);
break;
case "validationneeded":
walletManagerModule.connect(passcode, newPasscode);
break;
}
}
generate siganture
Auth
void _startSignatureProcess(String patternAuth) async {
debugPrint("Starting signature process with $patternAuth");
CustomerAuthenticatedSignatureModule customerAuthenticatedSignatureModule =
_flutterTreezorEntrustSdkBridgePlugin.getCustomerAuthenticatedSignatureModule(patternAuth, "", [payloadString]);
CustomCustomerAuthenticatedProcessCallback customCustomerAuthenticatedProcessCallback =
CustomCustomerAuthenticatedProcessCallback(
onCustomerCredentialsRequired: () => {
_signatureOnCustomerCredentialsRequired(patternAuth, customerAuthenticatedSignatureModule)
},
onCustomerCredentialsInvalid: (reason) => {
debugPrint("onCustomerCredentialsInvalid")
},
onProcessStart: () => {
debugPrint("onProcessStart")
},
onProcessSuccess: () => {
_signatureOnProcessSuccess(customerAuthenticatedSignatureModule)
},
onError: (error) => {
debugPrint("onError: $error")
},
onAuthenticationDeclined: () => {
debugPrint("onAuthenticationDeclined")
},
);
customerAuthenticatedSignatureModule.signWithCustomAuthentication(customCustomerAuthenticatedProcessCallback);
}
// Handle onCustomerCredentialsRequired based on patternAuth
void _signatureOnCustomerCredentialsRequired(String patternAuth, CustomerAuthenticatedSignatureModule customerAuthenticatedSignatureModule) {
debugPrint("onCustomerCredentialsRequired");
switch (patternAuth) {
case "PIN":
customerAuthenticatedSignatureModule.setPinCustomerCredentials(newPasscode);
break;
case "BIO":
customerAuthenticatedSignatureModule.setBioCustomerCredentials("Title", "SubTitle");
break;
case "NONE":
default:
customerAuthenticatedSignatureModule.setPinCustomerCredentials(newPasscode);
break;
}
}
// Handle onProcessSuccess
void _signatureOnProcessSuccess(CustomerAuthenticatedSignatureModule customerAuthenticatedSignatureModule) async {
debugPrint("onProcessSuccess");
String? scaResult = await customerAuthenticatedSignatureModule.getResult();
}