XuqmGroup-iOSSDK/Sources/XuqmCoreSDK/SDKConfig.swift

62 行
1.4 KiB
Swift

2026-04-21 22:07:29 +08:00
import Foundation
public struct SDKConfig: Sendable {
public let appKey: String
public let debug: Bool
public let autoRegisterPush: Bool
2026-04-21 22:07:29 +08:00
public init(
appKey: String,
debug: Bool = false,
autoRegisterPush: Bool = true
2026-04-21 22:07:29 +08:00
) {
self.appKey = appKey
self.debug = debug
self.autoRegisterPush = autoRegisterPush
2026-04-21 22:07:29 +08:00
}
}
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
}
}