feat: integrate JPush notifications
This commit is contained in:
30
suixinkan/Core/Push/PushAPI.swift
Normal file
30
suixinkan/Core/Push/PushAPI.swift
Normal file
@ -0,0 +1,30 @@
|
||||
import Foundation
|
||||
|
||||
/// 极光 Registration ID 上报能力,允许推送管理器注入测试替身。
|
||||
@MainActor
|
||||
protocol PushRegistrationServing: AnyObject {
|
||||
/// 将当前设备的极光 Registration ID 绑定到已登录业务账号。
|
||||
func registerJPushID(_ registrationID: String) async throws
|
||||
}
|
||||
|
||||
/// 推送 API,复用 Android 当前使用的 Registration ID 上报接口。
|
||||
@MainActor
|
||||
final class PushAPI: PushRegistrationServing {
|
||||
private let client: APIClient
|
||||
|
||||
/// 使用共享网络客户端创建推送 API。
|
||||
init(client: APIClient) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
/// 上报极光 Registration ID;后端字段名沿用 `jpush_reg_id`。
|
||||
func registerJPushID(_ registrationID: String) async throws {
|
||||
let _: EmptyPayload = try await client.send(
|
||||
APIRequest(
|
||||
method: .post,
|
||||
path: "/api/app/user/register-jpush-id",
|
||||
queryItems: [URLQueryItem(name: "jpush_reg_id", value: registrationID)]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user