As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
Is that possible to add more fields to the user collections or we have to create separate collections then use queries to get the data we want?
In my app, the user has more than just username and email. I am not sure what is the best way to deal with this problem.
Thanks
Best Answer
W
Wani
said
almost 8 years ago
Hi Charles,
Sorry if I was unclear before. Following are a couple of code snippets I think would solve this issue.
Sign up a new user with an extra field
[KCSUser
userWithUsername:@"kinvey"
password:@"12345"
fieldsAndValues:@{KCSUserAttributeEmail : @"kinvey@kinvey.com", KCSUserAttributeGivenname : @"Arnold", KCSUserAttributeSurname : @"Kinvey", @"dob" : @"07-05-61"}
withCompletionBlock:^(KCSUser user, NSError errorOrNil, KCSUserActionResult result) {
if (errorOrNil == nil)
{
//was successful!
}
else
{
//there was an error with the sign up
}
}];
Add a new field for a logged in user
[user setValue:@"NYC" forAttribute:@"city"];
[user saveWithCompletionBlock:^(NSArray objectsOrNil, NSError errorOrNil) {
if (errorOrNil == nil) {
//was successful!
} else {
//there was an error with the update save
}
}];
View a field other than preset values - e.g. date of birth - dob
NSLog(@"User's date of birth is - %@", [[user valueForKeyPath:@"userAttributes"] valueForKey:@"dob"]);
You can add as many fields as you want to the user collection. E.g. first name, last name, date of birth etc.
Regards,
Wani
C
Charles
said
almost 8 years ago
do I do it in the console? because everytime I add an extra column it just disappears after I refresh the page.
W
Wani
said
almost 8 years ago
You have two options to achieve this:
Using the console, add the new column and then add value for that column for one or more users.
Update KCSUser class definition with the new column and then update/add one or more users with values for the new column.
Regards,
Wani
C
Charles
said
almost 8 years ago
How do I update the KCSUser class definition? I cant seem to make it work correctly
W
Wani
said
almost 8 years ago
Answer
Hi Charles,
Sorry if I was unclear before. Following are a couple of code snippets I think would solve this issue.
Sign up a new user with an extra field
[KCSUser
userWithUsername:@"kinvey"
password:@"12345"
fieldsAndValues:@{KCSUserAttributeEmail : @"kinvey@kinvey.com", KCSUserAttributeGivenname : @"Arnold", KCSUserAttributeSurname : @"Kinvey", @"dob" : @"07-05-61"}
withCompletionBlock:^(KCSUser user, NSError errorOrNil, KCSUserActionResult result) {
if (errorOrNil == nil)
{
//was successful!
}
else
{
//there was an error with the sign up
}
}];
Add a new field for a logged in user
[user setValue:@"NYC" forAttribute:@"city"];
[user saveWithCompletionBlock:^(NSArray objectsOrNil, NSError errorOrNil) {
if (errorOrNil == nil) {
//was successful!
} else {
//there was an error with the update save
}
}];
View a field other than preset values - e.g. date of birth - dob
NSLog(@"User's date of birth is - %@", [[user valueForKeyPath:@"userAttributes"] valueForKey:@"dob"]);
Charles
Is that possible to add more fields to the user collections or we have to create separate collections then use queries to get the data we want?
In my app, the user has more than just username and email. I am not sure what is the best way to deal with this problem.Thanks
Hi Charles,
Sorry if I was unclear before. Following are a couple of code snippets I think would solve this issue.
Regards,
Wani
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstWani
Hi Charles,
You can add as many fields as you want to the user collection. E.g. first name, last name, date of birth etc.
Regards,
Wani
Charles
do I do it in the console? because everytime I add an extra column it just disappears after I refresh the page.
Wani
You have two options to achieve this:
Regards,
Wani
Charles
Wani
Hi Charles,
Sorry if I was unclear before. Following are a couple of code snippets I think would solve this issue.
Regards,
Wani
-
Why do I get "Undefined symbols" errors when building with KinveyKit?
-
How do I register push tokens?
-
When using social login, to perform a log-out, do I need to log out of the social network, Kinvey, o
-
How can I assign additional properties to users?
-
Does KinveyKit support 64-bit ARM devices, such as iPhone 5s?
-
Authorization Token Invalid or Expired
-
BOOL and how it is stored in the database.
-
Offline saving throwing errors
-
Custom endpoint not able to form request object
-
Security through business logic
See all 437 topics