Decide pending Operations
You can start the decision flow using three methods, from a link, from a notification or from fetched pending events. First, you need to start a decision flow, there are three ways to do it:
Client requirements
Create a decision flow
- iOS (Swift)
- Android (Java)
// using passing the operation object
let decision = try trustfactorClient.startOperationDecisionFlow(for: <TFOperation.ID>, applicationProfileId: <TFApplicationProfile.ID>, context: .history)
// using a decision URL (context is infered as ".deeplink")
let decision = try trustfactorClient.startOperationDecisionFlow(url: <URL>)
// using a notification (context is infered as ".pushNotification")
let decision = try trustfactorClient.startOperationDecisionFlow(notification: <UNNotification>)
// using passing the operation object
TFOperationDecisionFlow decision = trustFactorClient.startOperationDecision(operationId, profileId, TFOperationDecisionFlow.Context.HISTORY);
// using a decision URL (context is infered as ".deeplink")
TFOperationDecisionFlow decision = trustFactorClient.startOperationDecision(decisionUri);
// using a notification (context is infered as ".pushNotification")
try{
byte [] operationData = trustFactorClient.parsePushNotificationUserInfo(notificationPayload);
} catch(Exception e){
// handle error
}
if(operationData == null || operationData.length == 0) {
// handle error
}
TFOperationDecisionFlow decision = trustFactorClient.startOperationDecision(operationData);
Get operations details
- iOS (Swift)
- Android (Java)
// get details: mandatory
decision.getOperationDetails() { result in
switch result {
case .success(let operation):
// handle success
case .failure(let error):
// handle error
}
}
// get details: mandatory
decision.getOperationDetails((result) -> result.fold(
(TFOperation operation, String correlationId) -> {
// handle success
},
(Error error, String correlationId) -> {
// handle error
}
));
Add checkpoints
Checkpoints are not mandatory but we encourage their usage.
- iOS (Swift)
- Android (Java)
// Add this checkpoint if/when a Summary of the operation is shown to the user.
decision.addCheckpoint(.didShowOperationSummary)
// Add this checkpoint when the full list of details is presented to the user.
decision.addCheckpoint(.didShowOperationDetails)
// Add this checkpoint if/when a Summary of the operation is shown to the user.
decision.addCheckpoint(TFOperationDecisionFlow.Checkpoint.DID_SHOW_OPERATION_SUMMARY);
// Add this checkpoint when the full list of details is presented to the user.
decision.addCheckpoint(TFOperationDecisionFlow.Checkpoint.DID_SHOW_OPERATION_DETAILS);
Authentication
Some Operations require the user to authenticate using a PIN, Biometry or both. It's important to keep in mind that the validation of the required authentication mechanisms is only done during the decision.
Note: There's no need to set authentications if the user is rejecting the operation.
- iOS (Swift)
- Android (Java)
// add PIN authentication
if operationDetails.requiredAuthentications?.contains(.pin) {
try decision.addAuthentication(.pin(<string>))
}
// add biometric authentication
if operation.requiredAuthentications?.contains(.biometrics) {
try decision.addAuthentication(.biometric(context: <LAContext>))
}
// Add PIN authentication
if (operation.getRequiredAuthenticationList().contains(TFAuthenticationMechanism.PIN)) {
try {
decision.addAuthentication(TFAuthentication.pin(pin));
} catch (Exception exception) {
// Handle the exception
}
}
// Add biometric authentication
// cipher must be obtained from getBiometricDecryptCipher() and authenticated via BiometricPrompt's CryptoObject
if (operation.getRequiredAuthenticationList().contains(TFAuthenticationMechanism.BIOMETRIC)) {
try {
decision.addAuthentication(TFAuthentication.biometric(cipher));
} catch (Exception exception) {
// Handle the exception
}
}
Decision
- iOS (Swift)
- Android (Java)
decision.reject() { result, correlationId in
// handle result
}
// OR
decision.approve() { result, correlationId in
// handle result
}
decision.approve((result) -> result.fold(
(TFOperationDecisionResult value, String correlationId) -> {
// handle success
},
(Error error, String correlationId) -> {
// handle error
}
));
// OR
decision.reject((result) -> result.fold(
(TFOperationDecisionResult value, String correlationId) -> {
// handle success
},
(Error error, String correlationId) -> {
// handle error
}
));