Advertisement
Guest User

Untitled

a guest
Apr 1st, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. func handleRegister(email:String, password:String, username:String) {
  2.  
  3. //Create User
  4. FIRAuth.auth()?.createUser(withEmail: email, password: password, completion: { (user, err) in
  5.  
  6. if err != nil {
  7. print(err!.localizedDescription)
  8. return
  9. }
  10.  
  11. //Success! User Created!
  12.  
  13. if let userID = user?.uid {
  14.  
  15. //Create User Profile
  16. let databaseRef = FIRDatabase.database().reference()
  17. let usersRef = databaseRef.child("Users").child(userID)
  18.  
  19. let usernameValue = ["username":username]
  20.  
  21. usersRef.updateChildValues(usernameValue, withCompletionBlock: { (err, ref) in
  22.  
  23. if err != nil {
  24. print(err!.localizedDescription)
  25. return
  26. }
  27.  
  28. //Profile created and updated!
  29.  
  30. })
  31.  
  32. }
  33.  
  34. })
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement