import UIKit //import NIMSDK class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // 执行数据迁移(从 UserDefaults 到 Keychain) DataMigrationManager.performStartupMigration() // 预加载用户信息缓存 UserInfoManager.preloadCache() // 开启网络监控 // NetworkManager.shared.networkStatusChanged = { status in // print("🌍 网络状态更新:\(status)") // } #if DEBUG // 🔍 DES加密已切换到OC版本 // print("🔐 使用OC版本的DES加密") // DESEncryptOCTest.runInAppDelegate() // 网络诊断 - 使用完整的登录参数测试 // let testURL = URL(string: "http://192.168.10.211:8080/oauth/token")! // var request = URLRequest(url: testURL) // request.httpMethod = "POST" // request.setValue("application/json", forHTTPHeaderField: "Content-Type") // request.setValue("application/json", forHTTPHeaderField: "Accept") // request.setValue("zh-Hant", forHTTPHeaderField: "Accept-Language") // // // 添加完整的测试参数 // let testParameters: [String: Any] = [ // "ispType": "65535", // "phone": "3+TbIQYiwIk=", // "netType": 2, // "channel": "molistar_enterprise", // "version": "20.20.61", // "pub_sign": "2E7C50AA17A20B32A0023F20B7ECE108", // "osVersion": "16.4", // "deviceId": "b715b75715e3417c9c70e72bbe502c6c", // "grant_type": "password", // "os": "iOS", // "app": "youmi", // "password": "nTW/lEgupIQ=", // "client_id": "erban-client", // "lang": "zh-Hant-CN", // "client_secret": "uyzjdhds", // "Accept-Language": "zh-Hant", // "model": "iPhone XR", // "appVersion": "1.0.0" // ] // // do { // let jsonData = try JSONSerialization.data(withJSONObject: testParameters, options: .prettyPrinted) // request.httpBody = jsonData // // print("🛠 原生URLSession登录测试开始") // print("📍 测试端点: \(testURL.absoluteString)") // print("📦 请求参数: \(String(data: jsonData, encoding: .utf8) ?? "无法解析")") // // URLSession.shared.dataTask(with: request) { data, response, error in // DispatchQueue.main.async { // let statusCode = (response as? HTTPURLResponse)?.statusCode ?? -1 // let responseString = data != nil ? String(data: data!, encoding: .utf8) ?? "无法解析响应" : "无数据" // // print(""" // === 网络诊断结果 === // 🔗 URL: \(testURL.absoluteString) // 📊 响应状态码: \(statusCode) // ❌ 错误信息: \(error?.localizedDescription ?? "无") // 📦 原始数据: \(data?.count ?? 0) bytes // 📄 响应内容: \(responseString) // ================== // """) // } // }.resume() // } catch { // print("❌ JSON序列化失败: \(error.localizedDescription)") // } #endif // NIMConfigurationManager.setupNimSDK() return true } }