I have a class and i try to present an UIAlertController directly in it if there is an error. Is it possible to do that in SwiftUI?
My code (obviously not working) :
import Firebase
import Combine
class TestFirebaseAlertClass: ObservableObject {
var didChange = PassthroughSubject<TestFirebaseAlertClass, Never>()
func resetPassword(email: String, password: String, handler: @escaping AuthDataResultCallback) {
Auth.auth().sendPasswordReset(withEmail: email, completion: { error in
if let error = error {
let alert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
view.present(alert, animated: true, completion: nil)
}
})
}
}