
新增.gitignore、Podfile和Podfile.lock文件以管理项目依赖,添加README.md文件提供项目简介和安装步骤,创建NIMSessionManager、ClientConfig、LogManager和NetworkManager等管理类以支持网络请求和日志记录功能,更新AppDelegate和ContentView以集成NIM SDK和实现用户登录功能。
33 lines
1002 B
Swift
33 lines
1002 B
Swift
import Foundation
|
||
|
||
final class ClientConfig {
|
||
static let shared = ClientConfig()
|
||
private init() {}
|
||
|
||
func initializeClient() {
|
||
print("开始初始化客户端")
|
||
|
||
NetworkManager.shared.enhancedRequest(
|
||
path: "client/init",
|
||
method: .get,
|
||
responseType: Data.self
|
||
) { result in
|
||
switch result {
|
||
case .success(let response):
|
||
print("初始化成功,状态码:\(response.statusCode)")
|
||
if let data = response.data {
|
||
do {
|
||
let json = try JSONSerialization.jsonObject(with: data)
|
||
print("响应数据:\(json)")
|
||
} catch {
|
||
print("JSON解析失败:\(error)")
|
||
}
|
||
}
|
||
|
||
case .failure(let error):
|
||
print("初始化失败:\(error.localizedDescription)")
|
||
}
|
||
}
|
||
}
|
||
}
|