Delete Firebase user (async/await)

Swift, Firebase, Async/await

Delete Firebase user using Swift's async/await

swift

import Firebase public extension User { func delete() async throws { // swiftformat:disable:next redundantReturn return try await withCheckedThrowingContinuation { continuation in delete { error in if let error { continuation.resume(throwing: error) } else { continuation.resume() } } } } }

How to use?

do { try await Auth.auth().currentUser?.delete() print("User deleted") } catch { print("User deletion failed with error: \(error)") }