跳转到主要内容

接收结果

SDK 通过在采集会话期间所使用的监听器接口中定义的回调来返回采集结果。

UnicoSelfie
onSuccessSelfie

当图像成功采集时调用。返回一个包含以下内容的 ResultCamera 对象:

  • base64 — 已采集的图像;可用于在您的应用中显示预览。
  • encrypted — JWT 载荷,必须发送至您的后端以通过 REST API 完成生物特征验证。
@override
void onSuccessSelfie(ResultCamera result) {
final base64 = result.base64;
final encrypted = result.encrypted; // JWT to send to your backend
}
encrypted 使用说明
  • encrypted 属性严格用于通过 Client API 发送图像。不得对其进行解析或序列化——其特性可能在未提前通知的情况下发生变更。Unico 对因不当处理而造成的任何损失概不负责。
  • base64/encrypted 文件的大小可能因设备质量、生成的照片大小以及 Unico 的业务规则而有所不同。请勿在您的编程逻辑或基础设施中限制 SDK 生成的字符串大小。
Base64 转 bitmap(Android)

如果需要在 Android 上将 base64 转换为 bitmap,标准方法无法直接使用——需要先以逗号(,)分割字符串。请参阅 How to convert a Base64 string into a Bitmap image to show it in an ImageView?

onErrorSelfie

当采集过程中发生错误时调用。返回包含 getCode()getDescription()UnicoError 对象。有关完整的错误代码列表,请参阅错误处理

@override
void onErrorSelfie(UnicoError error) {
final code = error.getCode();
final description = error.getDescription();
}
UnicoDocument
onSuccessDocument

当证件图像成功采集时调用。返回一个包含以下内容的 ResultCamera 对象:

  • base64 — 已采集的图像;可用于显示预览。
  • encrypted — JWT 载荷,必须在 10 分钟内发送至您的后端,且不得对其进行修改或反序列化。
@override
void onSuccessDocument(ResultCamera result) {
final base64 = result.base64;
final encrypted = result.encrypted; // JWT to send to your backend
}
onErrorDocument

当证件采集过程中发生错误时调用。返回一个 UnicoError 对象。有关完整的错误代码列表,请参阅错误处理

@override
void onErrorDocument(UnicoError error) {
final code = error.getCode();
final description = error.getDescription();
}