Home / IOS Development / Catching certain Firebase errors in iOS does not work

Catching certain Firebase errors in iOS does not work



Updated question

I try to manually check if the user needs to be re-approved or not. This is what I have come up with:

    //MARK: updateEmail
static func updateEmail(email: String, finished: @escaping (_ done: Bool, _ hasToReauthenticate: Bool) -> Void) {
    let currentUser = Auth.auth().currentUser
    currentUser?.updateEmail(to: email) { err in
        if err != nil {
            if let errCode = AuthErrorCode(rawValue: err!._code) {
                switch errCode {
                case .userTokenExpired:
                    print("expired")
                    finished(true, true)
                    break
                default:
                    Utilities.showErrorPopUp(labelContent: "Fehler", description: err!.localizedDescription)
                    finished(false, false)
                }
            }
        } else {
            finished(true, false)
        }
    }
}

But this never goes through .userTokenExpired the case even when it should .. What am I missing here?


Source link