Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static func signUp(username: String, email: String, password: String, firstname: String, lastname: String, imageData: Data, onSuccess: @escaping () -> Void, onError: @escaping (_ errorMessage: String?) -> Void) {
- Auth.auth().createUser(withEmail: email, password: password) { (authData: AuthDataResult?, error: Error?) in
- if error != nil {
- onError(error?.localizedDescription)
- return
- }
- let uid = authData!.user.uid
- let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("profile_image").child(uid)
- storageRef.putData(imageData, metadata: nil, completion: { (_, error: Error?) in
- if error != nil {
- return
- }
- storageRef.downloadURL(completion: { (url: URL?, error: Error?) in
- if let profileImageUrl = url?.absoluteString {
- self.setUserInformation(profileImageUrl: profileImageUrl!, username: username, email: email, firstname: firstname, lastname: lastname, uid: uid, onSuccess: onSuccess)
- }
- }
- )}
- )}
- }
Add Comment
Please, Sign In to add comment