2026-04-21 22:07:29 +08:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
public struct SDKConfig: Sendable {
|
|
|
|
|
public let appKey: String
|
|
|
|
|
public let debug: Bool
|
2026-05-05 17:54:59 +08:00
|
|
|
public let autoRegisterPush: Bool
|
2026-04-21 22:07:29 +08:00
|
|
|
|
|
|
|
|
public init(
|
|
|
|
|
appKey: String,
|
2026-05-05 17:54:59 +08:00
|
|
|
debug: Bool = false,
|
|
|
|
|
autoRegisterPush: Bool = true
|
2026-04-21 22:07:29 +08:00
|
|
|
) {
|
|
|
|
|
self.appKey = appKey
|
|
|
|
|
self.debug = debug
|
2026-05-05 17:54:59 +08:00
|
|
|
self.autoRegisterPush = autoRegisterPush
|
2026-04-21 22:07:29 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-04-28 16:08:06 +08:00
|
|
|
|
|
|
|
|
public extension SDKConfig {
|
|
|
|
|
static func development(
|
2026-04-29 15:46:39 +08:00
|
|
|
appKey: String,
|
2026-05-05 17:54:59 +08:00
|
|
|
debug: Bool = false,
|
|
|
|
|
autoRegisterPush: Bool = true
|
2026-04-28 16:08:06 +08:00
|
|
|
) -> SDKConfig {
|
|
|
|
|
SDKConfig(
|
2026-04-29 15:46:39 +08:00
|
|
|
appKey: appKey,
|
2026-05-05 17:54:59 +08:00
|
|
|
debug: debug,
|
|
|
|
|
autoRegisterPush: autoRegisterPush
|
2026-04-28 16:08:06 +08:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-04-29 15:46:39 +08:00
|
|
|
|
2026-05-23 01:20:57 +08:00
|
|
|
public enum SDKEndpoints {
|
2026-06-11 12:25:16 +08:00
|
|
|
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
|
|
|
|
|
}
|
2026-04-29 15:46:39 +08:00
|
|
|
}
|