Firebase error handling while creating user Swift -
i developing ios application , wanted implement firebase database.
i'm facing issue while handling errors during users creation process. default error switch, here code :
firauth.auth()?.createuser(withemail: emailfield.text!, password: passwordfield.text!, completion: { (user, error) in if (error != nil) { if let errcode = firautherrorcode(rawvalue: error!._code) { var alertcontroller = uialertcontroller(title: "", message: "", preferredstyle: uialertcontrollerstyle.alert) let okbutton = uialertaction(title: "ok", style: uialertactionstyle.default) { (result: uialertaction) -> void in print("error transmitted") } switch errcode { case .errorcodeinvalidemail: print("invalid email") alertcontroller = uialertcontroller(title: "error", message: "email syntax not correct", preferredstyle: uialertcontrollerstyle.alert) alertcontroller.addaction(okbutton) self.present(alertcontroller, animated: true, completion: nil) case .errorcodeemailalreadyinuse: print("email in use") alertcontroller = uialertcontroller(title: "error", message: "this email in use", preferredstyle: uialertcontrollerstyle.alert) alertcontroller.addaction(okbutton) self.present(alertcontroller, animated: true, completion: nil) case .errorcodeweakpassword: print("password weak") alertcontroller = uialertcontroller(title: "error", message: "password weak. please choose password contains @ least 6 characters.", preferredstyle: uialertcontrollerstyle.alert) alertcontroller.addaction(okbutton) self.present(alertcontroller, animated: true, completion: nil) default: // here. print(error) alertcontroller = uialertcontroller(title: "error", message: "an unknown error occured.", preferredstyle: uialertcontrollerstyle.alert) alertcontroller.addaction(okbutton) self.present(alertcontroller, animated: true, completion: nil) } } } else { print("user created") let newuser = ["email": self.emailfield.text!] let firebasenewuser = self.ref.childbyautoid() firebasenewuser.setvalue(newuser) }
moreover, print(error) displays :
optional(error domain=firautherrordomain code=17999 "an internal error has occurred, print , inspect error details more information." userinfo={nsunderlyingerror=0x170257be0 { error domain=firauthinternalerrordomain code=3 "(null)" userinfo={firautherroruserinfodeserializedresponsekey={ code = 400; errors = ( { domain = usagelimits; message = "bad request"; reason = keyexpired; } ); message = "bad request"; }}}, error_name=error_internal_error, nslocalizeddescription=an internal error has occurred, print , inspect error details more information.})
can me please ?
try enabling identity toolkit api in google console.
Comments
Post a Comment