1

I am having a hard time updating an already registered user on Kinvey.

For example if I used this code to register a new user :

KCSUser.userWithUsername(
"kinvey",
password: "12345",
fieldsAndValues: [
    KCSUserAttributeEmail : "kinvey@kinvey.com",
    KCSUserAttributeGivenname : "Arnold",
    KCSUserAttributeSurname : "Kinvey"
],
withCompletionBlock: { (user: KCSUser!, errorOrNil: NSError!, result: KCSUserActionResult) -> Void in
    if errorOrNil == nil {
        //was successful!
        let alert = UIAlertView(
            title: NSLocalizedString("Account Creation Successful", comment: "account success note title"),
            message: NSLocalizedString("User created. Welcome!", comment: "account success message body"),
            delegate: nil,
            cancelButtonTitle: NSLocalizedString("OK", comment: "OK")
        )
        alert.show()
    } else {
        //there was an error with the update save
        let message = errorOrNil.localizedDescription
        let alert = UIAlertView(
            title: NSLocalizedString("Create account failed", comment: "Create account failed"),
            message: message,
            delegate: nil,
            cancelButtonTitle: NSLocalizedString("OK", comment: "OK")
        )
        alert.show()
    }
  }
)

How would I go about updating the KCSUserAttributeGivenname or KCSUserAttributeSurname.

Any help would be appreciated. Thank you

iNick
  • 105
  • 1
  • 11

1 Answers1

0

I have figured out how to successfully update a user. It would look something like this:

        KCSUser.activeUser().setValue("John", forAttribute: "first_name")
        KCSUser.activeUser().setValue("Doe", forAttribute: "last_name")

You would then just call .refreshFromServer to update the server and .saveWithCompletionBlock to save the updated changes to the back end.

iNick
  • 105
  • 1
  • 11