Firebase setValue on offline

Viewed 740

I would to save user data into firebase when he signup, But there is a problem which is if he created Auth account and then lost connection before saving his info, That's mean he will get Email\Password without any profile info.

So the question is how to setValue again if he lost connection or exit the app?

FIRAuth.auth()?.createUser(withEmail: self.emailTxt.text!, password: self.passTxt.text!, completion: {
        (user, error) in
        if error != nil {
            if let isError = error?.localizedDescription
            {
                print(isError)
            } else {
                print("Error: 33")
            }
        }
        else if user != nil
        {
            // Email and password created
            let userInfo: [String : Any] = ["timestamp": FIRServerValue.timestamp(),
                                            "uid" : user!.uid,
                                            "email" : self.emailTxt.text!,
              //  This info must be send again if its failed.
                                        ]
              self.ref.child("users").child("profile").child((user?.uid)!).setValue(userInfo) {
                (error, ref) in

                if error != nil {
                    print("error set profile info")
                    // What should i do if its failed? 
                } else {
                    print("done creating user's profile")
                }
        }
    }
    }// Completion end.
2 Answers
Related