Maybe fix continuation being reused

This commit is contained in:
Shadowfacts 2024-04-11 22:30:43 -04:00
parent 8a339ec171
commit 2e31d34e9d
1 changed files with 2 additions and 3 deletions

View File

@ -180,9 +180,6 @@ class PushManagerImpl: _PushManager {
} }
private func getDeviceToken() async throws -> Data { private func getDeviceToken() async throws -> Data {
defer {
remoteNotificationsRegistrationContinuation = nil
}
return try await withCheckedThrowingContinuation { continuation in return try await withCheckedThrowingContinuation { continuation in
remoteNotificationsRegistrationContinuation = continuation remoteNotificationsRegistrationContinuation = continuation
UIApplication.shared.registerForRemoteNotifications() UIApplication.shared.registerForRemoteNotifications()
@ -191,10 +188,12 @@ class PushManagerImpl: _PushManager {
func didRegisterForRemoteNotifications(deviceToken: Data) { func didRegisterForRemoteNotifications(deviceToken: Data) {
remoteNotificationsRegistrationContinuation?.resume(returning: deviceToken) remoteNotificationsRegistrationContinuation?.resume(returning: deviceToken)
remoteNotificationsRegistrationContinuation = nil
} }
func didFailToRegisterForRemoteNotifications(error: any Error) { func didFailToRegisterForRemoteNotifications(error: any Error) {
remoteNotificationsRegistrationContinuation?.resume(throwing: PushRegistrationError.registeringForRemoteNotifications(error)) remoteNotificationsRegistrationContinuation?.resume(throwing: PushRegistrationError.registeringForRemoteNotifications(error))
remoteNotificationsRegistrationContinuation = nil
} }
private func register(deviceToken: String) async throws -> PushProxyRegistration { private func register(deviceToken: String) async throws -> PushProxyRegistration {