Skip to main content

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

// 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)

Get operations details

// get details: mandatory
decision.getOperationDetails() { result in
switch result {
case .success(let operation):
// handle operation details

case .failure(let error):
// handle error
}
}

Add checkpoints

Checkpoints are not mandatory but we encourage their usage.

// 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)

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.

 // 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>))
}

Decision

decision.reject() { result, correlationId in
// handle result
}

// OR

decision.approve() { result, correlationId in
// handle result
}