- 添加 expiresAt 和 refreshUserSig 参数支持自动续签 - 修改 PushSDK 初始化方式,自动完成设备注册和厂商初始化 - 调整过期续签策略,从提前 15 分钟改为提前 5 分钟触发 - 重构 RN SDK 文档结构,简化安装和使用方式 - 更新统一登录流程,支持 profile 信息传递 - 添加 IM 数据库自动隔离功能 - 修复 Android 群消息聚合问题 - 补充自动化测试验证和错误处理机制
101 行
2.6 KiB
Swift
101 行
2.6 KiB
Swift
import SwiftUI
|
|
import XuqmSDK
|
|
|
|
@main
|
|
struct XuqmDemoApp: App {
|
|
#if canImport(UIKit)
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
#endif
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
}
|
|
}
|
|
}
|
|
|
|
#if canImport(UIKit)
|
|
class AppDelegate: NSObject, UIApplicationDelegate {
|
|
func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
) -> Bool {
|
|
initializeSDK()
|
|
return true
|
|
}
|
|
}
|
|
#endif
|
|
|
|
@MainActor
|
|
private func initializeSDK() {
|
|
let config = SDKConfig(
|
|
appKey: "ak_demo_chat",
|
|
appSecret: "demo_secret",
|
|
debug: true
|
|
)
|
|
XuqmSDK.shared.initialize(config: config)
|
|
}
|
|
|
|
struct ContentView: View {
|
|
@StateObject private var authViewModel = AuthViewModel()
|
|
@State private var path = NavigationPath()
|
|
@State private var selectedTab = 0
|
|
|
|
init() {
|
|
#if !canImport(UIKit)
|
|
initializeSDK()
|
|
#endif
|
|
}
|
|
|
|
var body: some View {
|
|
Group {
|
|
if case .success = authViewModel.state {
|
|
MainTabView(authViewModel: authViewModel, path: $path, selectedTab: $selectedTab)
|
|
} else {
|
|
NavigationStack {
|
|
LoginView(viewModel: authViewModel)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct MainTabView: View {
|
|
@ObservedObject var authViewModel: AuthViewModel
|
|
@Binding var path: NavigationPath
|
|
@Binding var selectedTab: Int
|
|
|
|
var body: some View {
|
|
NavigationStack(path: $path) {
|
|
TabView(selection: $selectedTab) {
|
|
ConversationListView(path: $path)
|
|
.tabItem {
|
|
Image(systemName: "message.fill")
|
|
Text("会话")
|
|
}
|
|
.tag(0)
|
|
|
|
UpdateCheckView()
|
|
.tabItem {
|
|
Image(systemName: "arrow.up.circle.fill")
|
|
Text("更新")
|
|
}
|
|
.tag(1)
|
|
|
|
ProfileView(authViewModel: authViewModel)
|
|
.tabItem {
|
|
Image(systemName: "person.fill")
|
|
Text("我的")
|
|
}
|
|
.tag(2)
|
|
}
|
|
.navigationDestination(for: AppRoute.self) { route in
|
|
switch route {
|
|
case .chat(let targetId, let targetName):
|
|
ChatView(targetId: targetId, targetName: targetName, currentUserId: authViewModel.currentUserId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|