28 行
811 B
Swift
28 行
811 B
Swift
|
|
import Foundation
|
||
|
|
|
||
|
|
public enum PushVendor: String {
|
||
|
|
case apns = "APNS"
|
||
|
|
case fcm = "FCM"
|
||
|
|
}
|
||
|
|
|
||
|
|
@MainActor
|
||
|
|
public final class PushSDK {
|
||
|
|
|
||
|
|
public static let shared = PushSDK()
|
||
|
|
private init() {}
|
||
|
|
|
||
|
|
public func registerToken(_ token: String, userId: String, vendor: PushVendor = .apns) async throws {
|
||
|
|
let config = XuqmSDK.shared.requireConfig()
|
||
|
|
let _: EmptyResponse = try await ApiClient.shared.request(
|
||
|
|
path: "/api/push/register",
|
||
|
|
method: "POST",
|
||
|
|
queryItems: [
|
||
|
|
URLQueryItem(name: "appId", value: config.appId),
|
||
|
|
URLQueryItem(name: "userId", value: userId),
|
||
|
|
URLQueryItem(name: "vendor", value: vendor.rawValue),
|
||
|
|
URLQueryItem(name: "token", value: token),
|
||
|
|
]
|
||
|
|
)
|
||
|
|
}
|
||
|
|
}
|