From 963e56a2321bf08a92c5688fb6dc49c9de5e7903 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 15 Aug 2025 21:50:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=AE=9A=E4=BD=8D=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/chat_api/SystemFunctionHandler.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/local_plugins/chat_api/ios/chat_api/Sources/chat_api/SystemFunctionHandler.swift b/local_plugins/chat_api/ios/chat_api/Sources/chat_api/SystemFunctionHandler.swift index 35d553698..6de9c42ce 100644 --- a/local_plugins/chat_api/ios/chat_api/Sources/chat_api/SystemFunctionHandler.swift +++ b/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()