Browse Source

上传定位服务检查

weicu
liwei1dao 1 year ago
parent
commit
f1e08b7e7e
  1. 9
      local_plugins/chat_api/ios/chat_api/Sources/chat_api/SystemFunctionHandler.swift

9
local_plugins/chat_api/ios/chat_api/Sources/chat_api/SystemFunctionHandler.swift

@ -447,10 +447,17 @@ private class GetCurrentLocationHandler: FunctionHandler {
return await withCheckedContinuation { continuation in
// 设置超时
let timeoutTask = Task {
try await Task.sleep(nanoseconds: 15_000_000_000) // 15秒
try await Task.sleep(seconds: 15) // 15秒
continuation.resume(returning: self.createErrorResponse(message: "位置获取超时,请检查网络连接后重试"))
}
// 检查位置服务是否可用
guard CLLocationManager.locationServicesEnabled() else {
locationCompletion?(Result(success: false, message: "位置服务未启用。请前往 设置 > 隐私与安全 > 定位服务 启用定位服务"))
locationCompletion = nil
return
}
LocationService.shared.getCurrentLocation { result in
timeoutTask.cancel()

Loading…
Cancel
Save