firebase - How to make a username mandatory in sign up page in swift -


i have created register page using firebase email , password auth. @ moment user not have enter username create account. how make mandatory them enter username?

        @iboutlet weak var nametextfield: uitextfield!     @iboutlet weak var emailtextfield: uitextfield!     @iboutlet weak var passwordtextfield: uitextfield!     @iboutlet weak var profileuploader: uiimageview!    var refd:firdatabasereference?     var refs: firstoragereference?      override func viewdidload() {         super.viewdidload()         refd = firdatabase.database().reference()         refs = firstorage.storage().reference()         profileuploader.layer.cornerradius = 2         profileuploader.clipstobounds = true     }      @ibaction func registertapped(_ sender: any) {         let namec = nametextfield.text         if let email = emailtextfield.text, let pass = passwordtextfield.text, let name = namec?.capitalized {             firauth.auth()?.createuser(withemail: email, password: pass, completion: { (user, error) in                 if user != nil {                     //user found                      let interval = nsdate().timeintervalsince1970                     let date = date(timeintervalsince1970: interval)                     let dateformatter = dateformatter()                   dateformatter.dateformat = "dd/mm/yyyy/hh/mm/ss"                     // can change date format whatever wants                     let datestring = dateformatter.string(from: date)                     print(datestring)                         self.refd?.child("users").child((user?.uid)!).setvalue(["email": email, "name": name, "user created": datestring])                     print("user created , added database", email, name, datestring)                     self.performsegue(withidentifier: "registertologin", sender: self)                 } 

swift 3x...

please change line

if let email = emailtextfield.text, let pass = passwordtextfield.text, let name = namec?.capitalized{  //code   }  

in line ...

 if let email = emailtextfield.text, let pass = passwordtextfield.text, let name = (namec?.capitalized.isempty)! ? nil:namec{{  //code   }  

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -