Remove transaction ID from push notifications registration

This commit is contained in:
Shadowfacts 2024-04-11 11:55:56 -04:00
parent ee992bc0bf
commit 9cf4975bfd
4 changed files with 5 additions and 7 deletions

View File

@ -31,7 +31,7 @@ class DisabledPushManager: _PushManager {
nil
}
func register(transactionID: UInt64) async throws -> PushProxyRegistration {
func register() async throws -> PushProxyRegistration {
throw Disabled()
}

View File

@ -50,7 +50,7 @@ public protocol _PushManager {
func updateSubscription(account: UserAccountInfo, alerts: PushSubscription.Alerts, policy: PushSubscription.Policy)
func pushSubscription(account: UserAccountInfo) -> PushSubscription?
func register(transactionID: UInt64) async throws -> PushProxyRegistration
func register() async throws -> PushProxyRegistration
func unregister() async throws
func updateIfNecessary(updateSubscription: @escaping (PushSubscription) async -> Bool) async

View File

@ -109,7 +109,7 @@ class PushManagerImpl: _PushManager {
subscriptions.first { $0.accountID == account.id }
}
func register(transactionID: UInt64) async throws -> PushProxyRegistration {
func register() async throws -> PushProxyRegistration {
guard remoteNotificationsRegistrationContinuation == nil else {
throw PushRegistrationError.alreadyRegistering
}
@ -203,7 +203,7 @@ class PushManagerImpl: _PushManager {
var request = URLRequest(url: url.url!)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "content-type")
request.httpBody = try! JSONEncoder().encode(PushRegistrationParams(transactionID: "TODO", environment: apnsEnvironment, deviceToken: deviceToken, pushVersion: 1))
request.httpBody = try! JSONEncoder().encode(PushRegistrationParams(environment: apnsEnvironment, deviceToken: deviceToken, pushVersion: 1))
let (data, resp) = try await URLSession.shared.data(for: request)
let status = (resp as! HTTPURLResponse).statusCode
guard (200...299).contains(status) else {
@ -286,13 +286,11 @@ enum CreateSubscriptionError: LocalizedError {
}
private struct PushRegistrationParams: Encodable {
let transactionID: String
let environment: String
let deviceToken: String
let pushVersion: Int
enum CodingKeys: String, CodingKey {
case transactionID = "transaction_id"
case environment
case deviceToken = "device_token"
case pushVersion = "push_version"

View File

@ -84,7 +84,7 @@ struct NotificationsPrefsView: View {
private func registerForRemoteNotifications() async -> Bool {
do {
pushProxyRegistration = try await PushManager.shared.register(transactionID: 0)
pushProxyRegistration = try await PushManager.shared.register()
return true
} catch {
self.error = .registering(error)