Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. FIRAuth.auth()?.createUserWithEmail(self.emailTextField.text, password: self.passwordTextField.text,
  2. withValueCompletionBlock: { error, result in
  3. if error != nil {
  4.  
  5.  
  6. //Change location of alertcontroller
  7. let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .Alert)
  8. let defaultAction = UIAlertAction(title: "Ok", style: .Cancel, handler: nil)
  9. alertController.addAction(defaultAction)
  10.  
  11.  
  12. } else {
  13. let uid = result["uid"] as? String
  14. println("Successfully created user account with uid: \(uid)")
  15.  
  16. // Create a new user dictionary accessing the user's info
  17. // provided by the authData parameter
  18. let newUser = [
  19. "provider": authData.provider,
  20. "displayName": authData.providerData["displayName"] as? NSString as? String,
  21. "firstName": firstnameTextField.text,
  22. "lastName": lastnameTextField.text
  23.  
  24. ]
  25. // Create a child path with a key set to the uid underneath the "users" node
  26. // This creates a URL path like the following:
  27. // - https://<YOUR-FIREBASE-APP>.firebaseio.com/users/<uid>
  28. ref.childByAppendingPath("users")
  29. .childByAppendingPath(authData.uid).setValue(newUser)
  30.  
  31. //
  32. // let firstName = firstnameTextField.text
  33. // let lastName = lastnameTextField.text
  34. // let user: NSDictionary = ["firstName": firstName!, "lastName": lastName! ]
  35. //
  36. //
  37. //
  38. // //add firebase child node
  39. // let profile = firebase.ref.childByAppendingPath(firstName!)
  40. //
  41. // // Write data to Firebase
  42. // profile.setValue(user)
  43.  
  44.  
  45. }
  46. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement