XuqmGroup-iOSSDK/Sources/XuqmSDK/Push/PushSDK.swift

30 行
855 B
Swift

2026-04-21 22:07:29 +08:00
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),
]
)
}
}
private struct EmptyResponse: Decodable {}