- 将 license.xuqm 文件替换为 config.xuqm 配置文件 - 实现 ConfigFileReader 来读取和解密配置文件 - 添加 ConfigFileCrypto 用于配置文件加密解密 - 更新 autoInitialize 方法以从配置文件自动初始化 - 移除对 sdk-license 的反射依赖 - 在 HarmonySDK 中实现配置端点动态配置 - 更新 iOS SDK 中的配置文件读取逻辑 - 统一各平台配置文件格式和处理方式
61 行
2.1 KiB
Swift
61 行
2.1 KiB
Swift
@_exported import XuqmCoreSDK
|
|
@_exported import XuqmImSDK
|
|
@_exported import XuqmPushSDK
|
|
@_exported import XuqmUpdateSDK
|
|
@_exported import XuqmLicenseSDK
|
|
@_exported import XuqmFileSDK
|
|
|
|
import Foundation
|
|
|
|
/// Auto-registers all feature module hooks with XuqmSDK.shared.
|
|
/// Import `XuqmSDK` to get the full SDK experience (backward compatible).
|
|
extension XuqmSDK {
|
|
|
|
/// Register all module hooks. Called automatically when any module is first used.
|
|
public func registerModuleHooks() {
|
|
// Note: licenseReader hook removed — autoInitialize now reads config.xuqm directly via ConfigFileReader.
|
|
|
|
// Initialize hook — auto-start push if configured
|
|
onInitialize = { @MainActor config in
|
|
if config.autoRegisterPush {
|
|
Task { @MainActor in
|
|
try? await PushSDK.shared.start()
|
|
}
|
|
}
|
|
}
|
|
|
|
// Login hook — connect IM and register push token
|
|
onLogin = { @MainActor userId, userSig in
|
|
try await ImSDK.shared.login(userId, userSig)
|
|
if let token = XuqmSDK.shared.cachedDeviceToken {
|
|
try await PushSDK.shared.registerToken(token, userId: userId)
|
|
}
|
|
}
|
|
|
|
// Logout hook — disconnect IM and unregister push
|
|
onLogout = { @MainActor userId in
|
|
ImSDK.shared.disconnect()
|
|
try await PushSDK.shared.unregisterToken(userId: userId)
|
|
}
|
|
|
|
// Device token hook — register with push service
|
|
onDeviceToken = { @MainActor token, userId in
|
|
try await PushSDK.shared.registerToken(token, userId: userId)
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Convenience initializer that auto-registers module hooks.
|
|
/// This provides backward compatibility for code that does `import XuqmSDK`.
|
|
@MainActor
|
|
public enum XuqmSDKSetup {
|
|
private static var hooksRegistered = false
|
|
|
|
/// Ensure module hooks are registered. Idempotent.
|
|
public static func ensureHooksRegistered() {
|
|
guard !hooksRegistered else { return }
|
|
hooksRegistered = true
|
|
XuqmSDK.shared.registerModuleHooks()
|
|
}
|
|
}
|