- 新增 API Key 管理功能,支持外部工具认证调用平台 API - 实现 WebSocket 实时通知,版本发布时推送轻量通知给客户端 - 添加 APK 文件哈希校验,支持已下载检测和直接安装 - 支持外部 APK 上传使用 API Key 认证 - 优化私有化部署自动注入 nginx WebSocket 代理配置 - 扩展 SDK 功能包括已下载检测、直接安装和实时通知监听
62 行
1.4 KiB
Swift
62 行
1.4 KiB
Swift
import Foundation
|
|
|
|
public struct SDKConfig: Sendable {
|
|
public let appKey: String
|
|
public let debug: Bool
|
|
public let autoRegisterPush: Bool
|
|
|
|
public init(
|
|
appKey: String,
|
|
debug: Bool = false,
|
|
autoRegisterPush: Bool = true
|
|
) {
|
|
self.appKey = appKey
|
|
self.debug = debug
|
|
self.autoRegisterPush = autoRegisterPush
|
|
}
|
|
}
|
|
|
|
public extension SDKConfig {
|
|
static func development(
|
|
appKey: String,
|
|
debug: Bool = false,
|
|
autoRegisterPush: Bool = true
|
|
) -> SDKConfig {
|
|
SDKConfig(
|
|
appKey: appKey,
|
|
debug: debug,
|
|
autoRegisterPush: autoRegisterPush
|
|
)
|
|
}
|
|
}
|
|
|
|
public enum SDKEndpoints {
|
|
private static var _apiBaseURL: URL?
|
|
private static var _imWebSocketURL: URL?
|
|
|
|
public static var apiBaseURL: URL {
|
|
_apiBaseURL ?? URL(string: "https://dev.xuqinmin.com")!
|
|
}
|
|
|
|
public static var imWebSocketURL: URL {
|
|
_imWebSocketURL ?? URL(string: "wss://dev.xuqinmin.com/ws/im")!
|
|
}
|
|
|
|
public static func configure(
|
|
apiBaseURL: String? = nil,
|
|
imWebSocketURL: String? = nil
|
|
) {
|
|
if let api = apiBaseURL, let url = URL(string: api) {
|
|
_apiBaseURL = url
|
|
}
|
|
if let ws = imWebSocketURL, let url = URL(string: ws) {
|
|
_imWebSocketURL = url
|
|
}
|
|
}
|
|
|
|
public static func reset() {
|
|
_apiBaseURL = nil
|
|
_imWebSocketURL = nil
|
|
}
|
|
}
|