跳到主要内容

重试服务鉴权

为一个 ServiceAuthType 请求重新鉴权。

API 参考

Swift
/// Retries authentication for the specified service.
/// - Parameters:
///   - service: The service whose authentication should be retried.
///   - completion: A closure that is called when the operation completes.
///     - success: `true` if the operation was successful; otherwise `false`.
///     - error: An `NSError` object that describes the error that occurred, or `nil` if the operation was successful.
func retryServiceAuth(
    _ service: ServiceAuthType,
    completion: AIBudsCompletionHandler?
)

请参阅 retryServiceAuth

SwiftObjective-C服务
.starBurstAIBudsServiceAuthTypeStarBurstStarBurst AI 服务
.onDeviceVoiceAssistantAIBudsServiceAuthTypeOnDeviceVoiceAssistant离线语音助手
Swift
guard let device = device as? DeviceServiceAuthAPI else { return }
device.retryServiceAuth(.starBurst) { success, error in
    if !success { print(error?.localizedDescription ?? "Authorization retry failed") }
}

完成回调仅表示重试请求已受理或失败;在判定服务已鉴权前,应读取更新后的鉴权状态或处理 SDK 鉴权回调。