Delete users

Permanently remove a user from App Context storage with Delete() or DeleteUser().

Both methods produce the same result. Call Delete() on a User object or DeleteUser() on the Chat object with the user ID.

Soft delete deprecated

Soft deletion for users has been deprecated. Delete() now always performs a hard delete. Use Delete() without any parameters to permanently remove a user. The soft parameter and Restore() method are no longer available for users.

Requires App Context

Enable App Context in the Admin Portal to store user data.

Method signature​

These methods take the following parameters:

  • Delete() (on the User object)

    1user.Delete()
  • DeleteUser() (on the Chat object)

    1chat.DeleteUser(string userId)

Input​

userId#
Type: string
Default: no default
Unique user identifier (up to 92 UTF-8 characters).
Required in Delete()
No
Required in DeleteUser()
Yes

Output​

TypeDescription
Task<ChatOperationResult>Returned Task that you can await to get the result of the delete operation.

Sample code​

Permanently delete user support_agent_15.

  • Delete() (on the User object)

    1using System.Threading.Tasks;
    2using PubnubApi;
    3using PubnubChatApi;
    4using UnityEngine;
    5
    6// Configuration
    7PubnubChatConfig chatConfig = new PubnubChatConfig();
    8
    9PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
    10{
    11 SubscribeKey = "demo",
    12 PublishKey = "demo",
    13 Secure = true
    14};
    15
    show all 29 lines
  • DeleteUser() (on the Chat object)

    1using System.Threading.Tasks;
    2using PubnubApi;
    3using PubnubChatApi;
    4using UnityEngine;
    5
    6// Configuration
    7PubnubChatConfig chatConfig = new PubnubChatConfig();
    8
    9PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
    10{
    11 SubscribeKey = "demo",
    12 PublishKey = "demo",
    13 Secure = true
    14};
    15
    show all 22 lines

Was this page useful?

Last updated on