---
title: 用户旅程
canonical: https://developer.unico.io/zh-CN/dual-api/developers/sdks-and-tools/ios/capture-flow/capture-types/user-journeys
locale: zh-CN
generated_by: markdown-export
---

用户旅程是由 SDK 结合已配置的流程编排的多步骤采集会话。例如，包含 活体检测 + 风险评分 + 文档采集与重用 + 电子签名的流程，在单个会话中依次执行自拍、文件采集和签名。

:::secondary[产品]
可用的旅程取决于为您的集成配置的流程。请参阅[产品](/products)，了解产品 → 流程 → 能力的完整映射。
:::

## 工作原理

SDK：

1. 读取初始化时提供的流程配置。
2. 编排该流程所需的采集序列（自拍、文件、签名）。
3. 当旅程完成时，通过 `onSuccess` 返回 `processId`。对于自拍步骤，图像数据（`base64` / `encrypted`）也通过 `onSuccessSelfie` 返回。文件和签名捕获由SDK在内部处理——不会向客户端暴露每步的工件。

编排完全由 SDK 处理——您无需在应用中实现步骤序列。

## 启动用户旅程

****步骤 2** — 实现 `AcessoBioSelfieDelegate`**

重写方法以处理旅程采集结果回调：

  | 方法 | 描述 |
  |---|---|
  | `onSuccessSelfie(result)` | 图像采集成功——返回用于后续 REST API 调用的 `SelfieResult` |
  | `onSuccess(result)` | 旅程成功完成——返回用于查询验证结果的 `processId` |
  | `onErrorSelfie(errorBio)` | 采集失败——返回包含错误详情的 `ErrorBio` |

  ### Swift

    ```swift
    class ViewController: UIViewController, AcessoBioManagerDelegate,
      SelfieCameraDelegate, AcessoBioSelfieDelegate {

      func onSuccessSelfie(_ result: SelfieResult!) { }
      func onSuccess(_ result: SuccessResult!) { }
      func onErrorSelfie(_ errorBio: ErrorBio!) { }
    }
    ```

### Objective-C

    ```objectivec
    @interface ViewController: UIViewController <AcessoBioManagerDelegate,
      SelfieCameraDelegate, AcessoBioSelfieDelegate>
    @end

    @implementation ViewController
    - (void)onSuccessSelfie:(SelfieResult *)result { }
    - (void)onSuccess:(SuccessResult *)result { }
    - (void)onErrorSelfie:(ErrorBio *)errorBio { }
    @end
    ```

****步骤 3** — 调用 `prepareSelfieCamera` 和 `open`**

调用 `prepareSelfieCamera` 并传入 SDK 配置。摄像头就绪后，`onCameraReady` 事件将触发——通过 `open()` 方法传入 `webAppToken` 打开摄像头：

  :::info[webAppToken]
  `webAppToken` 是在后端创建流程时，`POST /client/v1/process` 返回的 `process.webAppToken` 字段。请参阅[创建流程](/dual-api/developers/api-reference/web-sdk/post-process)。
  :::

  - `onCameraReady(cameraOpener)` — 摄像头已就绪；调用 `open(self, webAppToken:)`。
  - `onCameraFailed(message)` — 摄像头准备失败（`ErrorPrepare` 是 `ErrorBio` 的扩展）。

  ### Swift

    ```swift
    @IBAction func openCamera(_ sender: Any) {
      unicoCheck.build().prepareSelfieCamera(self, config: YourUnicoConfigClass())
    }

    func onCameraReady(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
      cameraOpener.open(self, webAppToken: "your_web_app_token")
    }

    func onCameraFailed(_ message: ErrorPrepare!) { }
    ```

### Objective-C

    ```objectivec
    - (IBAction)openCamera:(UIButton *)sender {
        [[unicoCheck build] prepareSelfieCamera:self config:[YourUnicoConfigClass new]];
    }

    - (void)onCameraReady:(id)cameraOpener {
        [cameraOpener open:self webAppToken:@"your_web_app_token"];
    }

    - (void)onCameraFailed:(ErrorPrepare *)message { }
    ```

有关完整的结果处理，请参阅[接收结果](/developers/sdks-and-tools/ios/capture-flow/receiving-the-result)。