I'm super stuck on this because the Syncano docs aren't great at explaining...
I'm building a simple chat app with Syncano backend (R.I.P Parse) and all I want to do is save the First Name, Last Name, and a unique username which they can pick. I have managed to connect the user to the server already and can see them in my list of classes, but the additional info for the user doesn't show. I have a view controller called Signup View Controller
which handles all the interaction with the labels and button all connected. It is worth mentioning this is my first app and I am a beginner in programming, so I need someone with a little bit experience to give me a few pointers on which its not saving the users Name and unique username.
This is the how I want to send the data to Syncano when pressed:
class SignupViewController: UIViewController {
var delegate : LoginDelegate?
var @IBAction func signupPressed(sender: AnyObject) {
var huddleusernameText = usernameTextField.text
var firstNameText = firstNameTextField.text
var lastNameText = lastNameTextField.text
var passwordText = passwordTextField.text
var repeatPasswordText = repeatPasswordTextField.text
var emailText = emailTextField.text
func registerUser(username: String, password: String, first_name: String, last_name: String, email: String)
{
SCUser.registerWithUsername(username, password: password)
{ error in
//handle user registration
if (error != nil)
{
//handle error
print("Sign Up, error: \(error)")
}
}
}
self.signUp(self.getUsername()!, password: self.getPassword()!, finished:
{ error in
if (error != nil) {
//handle error
print("Sign Up, error: \(error)")
} else
{
SCUser.currentUser()
self.addNewUser()
self.delegate?.didSignUp()
}
})
func signUp(username: String, password: String, finished: (NSError!) -> ()) {
SCUser.registerWithUsername(username, password: password) { error in
finished(error)
}
}
// Syncano docs mentions using this, but I'm not sure how to use this piece of code to store user data...
class MyUserProfile : SCUserProfile {
var avatar : SCFile? = nil;
var first_name = ""
var last_name = ""
var email = ""
var username = ""
}
This is something additional
func addNewUser() {
let user = MyUserProfile()
user.first_name = firstNameTextField.text!
user.last_name = lastNameTextField.text!
user.email = emailTextField.text!
user.huddle_username = usernameTextField.text!
user.saveWithCompletionBlock { error in
//Handle error
}
}
I will update this question if I run into any new solutions but for now, this is it.