After a user signs up in my iOS app, I want to automatically create a new userCategory
object for them. My approach was to use Parse cloud code to trigger the creation of this object once the signup process is successful. However, after checking Parse's databrowser, I noticed that while the new user is created, their associated userCategory
is missing.
Here is the Objective-C code:
// Delegate method called when a PFUser is signed up.
- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user {
[self dismissViewControllerAnimated:YES completion:NULL];
[PFCloud callFunctionInBackground:@"userCategoryCreate"
withParameters:@{}
block:^(NSNumber *ratings, NSError *error) {
if (!error) {
// UserCategory successfully created
}
}];
}
And here is the corresponding Cloud Code:
Parse.Cloud.define("userCategoryCreate", function(request, response) {
// Simple syntax to create a new subclass of Parse.Object.
var UserCategory = Parse.Object.extend("UserCategory");
// Create a new instance of that class.
var userCategory = new UserCategory();
response.success("UserCategory successfully created!");
});