Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if emailUserPicString == "" {
- let alertController = UIAlertController(title: "Profile Picture Error", message: "Don't forget to choose a profile picture!", preferredStyle: UIAlertControllerStyle.alert)
- let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(alert :UIAlertAction!) in
- })
- alertController.addAction(okAction)
- self.present(alertController, animated: true, completion: nil)
- return
- } else {
- self.performSegue(withIdentifier: "emailToSetup", sender: nil)
- }
- @IBAction func emailSignupNextPressed(_ sender: Any) {
- // Make sure text fields aren't empty
- guard nameField.text != "", emailField.text != "", passwordField.text != "", confirmPasswordField.text != "" else {return}
- if passwordField.text == confirmPasswordField.text {
- Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
- if let error = error {
- print(error.localizedDescription)
- }
- if let user = user {
- guard let uid = Auth.auth().currentUser?.uid else {return}
- // Use name as Firebase display name for readability
- let changeRequest = Auth.auth().currentUser!.createProfileChangeRequest()
- changeRequest.displayName = self.nameField.text!
- changeRequest.commitChanges(completion: nil)
- // Create child node from userStorage "users". Profile image set to user's unique ID
- let imageRef = self.userStorage.child("(uid).jpg")
- let data = UIImageJPEGRepresentation(self.selectProfileImageView.image!, 0.5)
- // Upload image to Firebase
- let uploadTask = imageRef.putData(data!, metadata: nil, completion: { (metadata, err) in
- if err != nil {
- print(err!.localizedDescription)
- }
- imageRef.downloadURL(completion: { (url, er) in
- if er != nil {
- print(er?.localizedDescription as Any)
- }
- if let url = url {
- emailUserPicString = url.absoluteString
- print("nnnpic:(emailUserPicString)nnn")
- if emailUserPicString == "" {
- let alertController = UIAlertController(title: "Profile Picture Error", message: "Don't forget to choose a profile picture!", preferredStyle: UIAlertControllerStyle.alert)
- let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: {(alert :UIAlertAction!) in
- })
- alertController.addAction(okAction)
- self.present(alertController, animated: true, completion: nil)
- return
- } else {
- self.performSegue(withIdentifier: "emailToSetup", sender: nil)
- }
- }
- })
- })
- uploadTask.resume()
- }
- })
- } else {
- print("Passwords don't match")
- passwordAlert()
- }
- }
Add Comment
Please, Sign In to add comment