Deleting a user

I’m using a backendless database to store users, and managing user creation and login through an Objective C interface from iOS. All working well, for example I use this code to register a new user

[Backendless.shared.userService registerUserWithUser:user responseHandler:^(BackendlessUser *registeredUser

Now Apple is requiring me to provide an option to delete a users data, and I can’t seem to find anything in the docs where I can do that. Is there a way that I can delete the logged in user

   [Backendless.shared.userService loginWithIdentity:user password:pwd responseHandler:^(BackendlessUser *theUser) {
        loggedInUser = theUser;

Or just directly delete them from the database?

Hi Andrew,

Deleting them directly from the database is the way to go. Get the user’s objectId value and then use the following API call:
https://backendless.com/docs/ios/data_single_object_deletion.html

Regards,
Mark

Thanks Mark!

I did try this code but I get an error on the response handler

[dataStore removeWithEntity:loggedInUser responseHandler:^(NSNumber *removed) {
    NSLog(@"user has been deleted");
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];

Incompatible block pointer types sending ‘void (^)(NSNumber *__strong)’ to parameter of type ‘void (^ _Null_unspecified)(NSInteger)’

Hello @Andrew_Smith,

Sorry for this inconvenience. I’ve created an internal ticket BKNDLSS-29098 to investigate this issue.

Regards,
Olha

Hello @Andrew_Smith,

Please make sure to have the latest version of Backendless SDK (6.6.0 for the moment).
Also the removeWithEntityMethod requires the Integer type in the response not the NSNumber one.
This should work:

[dataStore removeWithEntity:user responseHandler:^(NSInteger removed) {
    NSLog(@"user has been deleted");
} errorHandler:^(Fault *fault) {
    NSLog(@"Error: %@", fault.message);
}];

Great, easy fix!

Actually just a documentation bug

https://backendless.com/docs/ios/data_single_object_deletion.html

I’ve created an internal ticket BKNDLSS-29118 to update documentation.