|
|
|
@ -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() |
|
|
|
|
|
|
|
|