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.startOperationDecision(for: <TFOperation.RawIdentifier>, on: <TFApplicationProfile.RawIdentifier>, context: .history)
// using a decision URL (context is infered as ".deeplink")
let decision = try trustfactorClient.startOperationDecision(url: <URL>)
// using a notification (context is infered as ".pushNotification")
guard case let .operation(operationData, error) = try trustfactorClient.parsePushNotificatioUserInfo(_ userInfo: <[AnyHashable: Any]>) else {
return // not the notification type we expect here
}
guard let operationData, error == nil else {
// handle error
}
let decision = try trustfactorClient.startOperationDecision(for: operationData)
// using passing the operation object
TFOperationDecisionFlow decision = trustFactorClient.startOperationDecisionFlow(operationId: <String>, profileId: <String>, TFOperationDecisionFlow.Context.HISTORY);
// using a decision URL (context is infered as ".deeplink")
TFOperationDecisionFlow decision = trustFactorClient.startOperationDecisionFlow(deeplink: <Uri>);
// using a notification (context is infered as ".pushNotification")
try{
byte [] operationData = trustFactorClient.parsePushNotificatioUserInfo(userInfo: <byte []>);
} catch(Exception e){
// handle error
}
if(operationData == null || operationData.length == 0) {
// handle error
}
TFOperationDecisionFlow decision = trustFactorClient.startOperationDecisionFlow(operationData: <byte []>);
Get operations details
- iOS (Swift)
- Android (Java)
// get details: mandatory
decision.getOperationDetails() { result in
switch result {
case .success(let operation):
// handle operation details
case .failure(let error):
// handle error
}
}
// get details: mandatory
decision.getOperationDetails(new Result<TFOperation, Error>() {
@Override
public void onSuccess(TFOperation result, String correlationId) {
// handle operation details
}
@Override
public void onFailure(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.PASSWORD)) {
try {
decision.addAuthentication(AuthType.PASSWORD, String pin);
} catch (Exception exception) {
// Handle the exception
}
}
// add biometric authentication
if (operation.getRequiredAuthenticationList().contains(TFAuthenticationMechanism.BIOMETRIC)) {
try {
decision.addAuthentication(TFAuthenticationMechanism.BIOMETRIC, String pin);
} 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.accept(new Result<Boolean, Error>() {
@Override
public void onSuccess(Boolean result) {
// handle result
}
@Override
public void onFailure(Error error) {
// handle error
}
});
// OR
decision.reject(new Result<Boolean, Error>() {
@Override
public void onSuccess(Boolean result, String correlationId) {
// handle result
}
@Override
public void onFailure(Error error, String correlationId) {
// handle error
}
});