Deleting a User

Sometimes users wish to remove themselves from your application, and you might want to permanently delete their accounts.

To delete the currently logged-in user, please execute the delete method.

  • // Get the currently logged-in user.
    KiiUser user = KiiUser.getCurrentUser();
    
    try {
      // Delete the user.
      user.delete();
    } catch (IOException e) {
      // Handle the error.
    } catch (AppException e) {
      // Handle the error.
    }
  • // Get the currently logged-in user.
      KiiUser user = KiiUser.getCurrentUser();
    
    // Delete the user.
    user.delete(new KiiUserCallBack() {
      @Override
      public void onDeleteCompleted(int token, Exception exception) {
        if (exception != null) {
          // Handle the error.
          return;
        }
      }
    });

When a user is deleted, all data that belong to this user (i.e. buckets, KiiObjects, topics, and device installation) will be automatically deleted.

Note that a group and its data (i.e. buckets, KiiObjects, and topics) will not be deleted even if the group owner or the last group member is deleted.

The users can only delete themselves. A group owner cannot delete the group members.

If the user deletion succeeds, the login state is cancelled and the user is treated as an anonymous user.

You can also delete pseudo users by executing the method while they are logged in with their access tokens.