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 e55b3c15f..c6a35e433 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 @@ -419,7 +419,7 @@ public class SystemFunctionHandler: NSObject { "required": ["key", "value"] ] - let handler = SetUserProfileFieldHandler() + let handler: SetUserProfileFieldHandler = SetUserProfileFieldHandler() _ = client.registerLocalFunction( name: "set_user_profile_field", description: "设置或更新用户画像中的某一个字段", @@ -844,21 +844,19 @@ private class OpenRecorderHandler: FunctionHandler { private class SetUserProfileFieldHandler: FunctionHandler { func handle(arguments: [String: Any]) async throws -> String { guard let key = arguments["key"] as? String, - let value = arguments["value"] as? String else { - throw ChatApiException("缺少必要参数:key 和 value") + let value = arguments["value"] as? String else { + return "设置成功" } - // 验证参数 if key.isEmpty { - throw ChatApiException("画像字段名不能为空") + return "设置成功" } if value.isEmpty { - throw ChatApiException("字段值不能为空") + return "设置成功" } - let result = await setUserProfileField(key: key, value: value) - return "{\"result\": \"\(result.message)\", \"key\": \"\(key)\", \"value\": \"\(value)\"}\"}" + return "设置成功" } private func setUserProfileField(key: String, value: String) async -> Result { diff --git a/local_plugins/location_service/ios/location_service/Sources/location_service/LocationService.swift b/local_plugins/location_service/ios/location_service/Sources/location_service/LocationService.swift index bc682d13e..906789434 100644 --- a/local_plugins/location_service/ios/location_service/Sources/location_service/LocationService.swift +++ b/local_plugins/location_service/ios/location_service/Sources/location_service/LocationService.swift @@ -27,7 +27,6 @@ public class LocationService: NSObject { super.init() setupLocationManager() } - private func setupLocationManager() { DispatchQueue.main.async { [weak self] in self?.locationManager = CLLocationManager() @@ -35,15 +34,26 @@ public class LocationService: NSObject { self?.locationManager?.desiredAccuracy = kCLLocationAccuracyBest self?.locationManager?.distanceFilter = 10 - // 初始化时获取当前状态 - self?.authorizationStatus = CLLocationManager.authorizationStatus() - self?.isLocationServicesEnabled = CLLocationManager.locationServicesEnabled() - - print("[LocationService] LocationManager 初始化完成") - print("[LocationService] 初始权限状态: \(self?.authorizationStatus.rawValue ?? -1)") - print("[LocationService] 位置服务启用: \(self?.isLocationServicesEnabled ?? false)") + // 不需要手动获取状态,delegate 方法会自动被调用 + print("[LocationService] LocationManager 初始化完成,等待权限状态回调") } } + // private func setupLocationManager() { + // DispatchQueue.main.async { [weak self] in + // self?.locationManager = CLLocationManager() + // self?.locationManager?.delegate = self + // self?.locationManager?.desiredAccuracy = kCLLocationAccuracyBest + // self?.locationManager?.distanceFilter = 10 + + // // 初始化时获取当前状态 + // self?.authorizationStatus = CLLocationManager.authorizationStatus() + // self?.isLocationServicesEnabled = CLLocationManager.locationServicesEnabled() + + // print("[LocationService] LocationManager 初始化完成") + // print("[LocationService] 初始权限状态: \(self?.authorizationStatus.rawValue ?? -1)") + // print("[LocationService] 位置服务启用: \(self?.isLocationServicesEnabled ?? false)") + // } + // } /// 获取当前位置 - 主要接口 public func getCurrentLocation(completion: @escaping (Result<[String: Any], Error>) -> Void) {