D. Managing Retakes
This guide describes how to use Entrupy’s retake workflow for items that require additional images to complete authentication.
A retake is triggered when the original submission contains blurry, unclear, or missing images. Entrupy requests these additional captures so the authentication can be completed accurately.
Overview
The retake process consists of two parts:
- Search for pending retakes – Retrieve items with active retake requests.
- Capture retake images – Launch the modal retake workflow for a specific item.
Both operations require valid authorization and delegate implementation.
1. Searching for Pending Retakes
Use searchRetakes() to fetch all items with pending retake requests.
Implement the EntrupySearchRetakeDelegate protocol to handle responses from this method.
import EntrupySDK
// Conform to the search delegate
class RetakeManager: EntrupySearchRetakeDelegate {
func fetchPendingRetakes() {
// Verify authorization
guard EntrupyApp.sharedInstance().isAuthorizationValid() else {
print("User not authorized")
return
}
// Assign the delegate BEFORE calling searchRetakes()
EntrupyApp.sharedInstance().searchRetakeDelegate = self
// Trigger the search
EntrupyApp.sharedInstance().searchRetakes()
}
// MARK: - Handle Success
func didSearchRetakesCompleteSuccessfully(_ result: [String: Any]) {
// EntrupySearchResult is provided by the Entrupy SDK.
// The result dictionary can be decoded into this model.
do {
let data = try JSONSerialization.data(withJSONObject: result)
let searchResult = try JSONDecoder().decode(EntrupySearchResult.self, from: data)
// Extract items with pending retake requests
let items = searchResult.items
if items.isEmpty {
print("No pending retake requests.")
} else {
print("Pending retake items: \(items.count)")
let ids = items.map { $0.entrupy_id }
print("Entrupy IDs requiring retake: \(ids)")
}
} catch {
print("Failed to decode EntrupySearchResult: \(error)")
}
}
// MARK: - Handle Failure
func didSearchRetakesFailWithError(
_ errorCode: EntrupyErrorCode,
description: String,
localizedDescription: String
) {
// Display an actionable error to the user
print("searchRetakes() failed: \(localizedDescription) [\(errorCode)]")
}
}
2. Capturing Retake Images
- Use
startRetakeCaptureForItem(withEntrupyID:)to launch the Entrupy retake interface for a specific item. - You must implement
EntrupyRetakeCaptureDelegateto receive completion, cancellation, timeout, and error results.
import EntrupySDK
class RetakeViewController: UIViewController, EntrupyRetakeCaptureDelegate {
func showEntrupyRetakeView(for entrupyId: String) {
guard EntrupyApp.sharedInstance().isAuthorizationValid() else {
print("User not authorized. Please log in first.")
return
}
// Assign delegate before launching the workflow
EntrupyApp.sharedInstance().retakeCaptureDelegate = self
// Launch the Entrupy retake workflow
EntrupyApp.sharedInstance().startRetakeCaptureForItem(withEntrupyID: entrupyId)
}
// MARK: - EntrupyRetakeCaptureDelegate
/// Successful retake completion
func didRetakeCaptureCompleteSuccessfully(
_ result: [AnyHashable: Any],
forItemWithEntrupyID entrupyID: String
) {
// Decode using EntrupyCaptureResult (provided by the SDK)
do {
let data = try JSONSerialization.data(withJSONObject: result)
let captureResult = try JSONDecoder().decode(EntrupyCaptureResult.self, from: data)
refreshItemState(with: captureResult)
} catch {
print("Failed to decode retake capture result: \(error)")
}
}
/// User cancelled manually
func didUserCancelRetakeCaptureForItem(withEntrupyID entrupyID: String) {
print("Retake capture cancelled for: \(entrupyID)")
}
/// SDK reported a failure
func didRetakeCaptureFailWithError(
_ errorCode: EntrupyErrorCode,
description: String,
localizedDescription: String,
forItemWithEntrupyID entrupyID: String
) {
print("Retake capture failed for \(entrupyID): \(localizedDescription) with error code : \(errorCode)")
}
/// Retake session timed out
func didRetakeCaptureTimeoutForItem(withEntrupyID entrupyID: String) {
print("Retake capture timed out for: \(entrupyID)")
}
// MARK: - Helpers
private func refreshItemState(with result: EntrupyCaptureResult) {
// Implement any app-specific integration behavior here.
}
}
3. Next Steps
- Review the Retake Flow UI Guide.
- Use the Detail View Controller Guide to review item status, history timeline, manage flags, and update SKU.