diff --git a/Sources/FirebaseAuth/FirebaseUser+Swift.swift b/Sources/FirebaseAuth/FirebaseUser+Swift.swift index 0c3cb37..b08b93d 100644 --- a/Sources/FirebaseAuth/FirebaseUser+Swift.swift +++ b/Sources/FirebaseAuth/FirebaseUser+Swift.swift @@ -235,11 +235,33 @@ public final class User { // } public func delete(completion: ((Error?) -> Void)?) { - fatalError("\(#function) not yet implemented") + deleteImpl() { error in + if let completion { + DispatchQueue.main.async { + completion(error) + } + } + } } public func delete() async throws { - fatalError("\(#function) not yet implemented") + try await withCheckedThrowingContinuation { (continuation: CheckedContinuation) in + deleteImpl() { error in + if let error { + continuation.resume(throwing: error) + } else { + continuation.resume() + } + } + } + } + + private func deleteImpl(completion: @escaping (Error?) -> Void) { + let future = swift_firebase.swift_cxx_shims.firebase.auth.user_delete(impl) + future.setCompletion({ + let (_, error) = future.resultAndError { AuthErrorCode($0) } + completion(error) + }) } public func sendEmailVerification(beforeUpdatingEmail email: String) async throws { diff --git a/Sources/firebase/include/FirebaseAuth.hh b/Sources/firebase/include/FirebaseAuth.hh index 41f3727..9f55ea9 100644 --- a/Sources/firebase/include/FirebaseAuth.hh +++ b/Sources/firebase/include/FirebaseAuth.hh @@ -52,6 +52,12 @@ user_reload(::firebase::auth::User user) { user.Reload()); } +inline ::swift_firebase::swift_cxx_shims::firebase::VoidFuture +user_delete(::firebase::auth::User user) { + return ::swift_firebase::swift_cxx_shims::firebase::VoidFuture::From( + user.Delete()); +} + inline ::swift_firebase::swift_cxx_shims::firebase::Future< ::firebase::auth::AuthResult> user_reauthenticate_and_retrieve_data(