On this page

Delete users

Remove users with delete() or deleteUser().

  • delete() - call on a User object (no ID needed)
  • deleteUser() - call on a Chat object (requires user ID)
Requires App Context

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

Method signature

These methods take the following parameters:

  • delete()

    1user.delete(): PNFuture<Unit>
  • deleteUser()

    1fun deleteUser(id: String): PNFuture<Unit>

Input

ParameterRequired in delete()Required in deleteUser()Description
id
Type: String
Default:
n/a
No
Yes
Unique user identifier (up to 92 UTF-8 characters).

Output

MethodDescription
delete()
Type: PNFuture<Unit>
Returns when the user is successfully deleted.
deleteUser()
Type: PNFuture<Unit>
Returns when the user is successfully deleted.

Sample code

Delete user support_agent_15.

  • delete()

    1// reference the "chat" object and invoke the "getUser()" method
    2chat.getUser("support_agent_15").async { result ->
    3 result.onSuccess { user ->
    4 // delete the user
    5 user.delete().async { deleteResult ->
    6 deleteResult.onSuccess {
    7 // handle success
    8 println("User successfully deleted.")
    9 }.onFailure { exception ->
    10 // handle failure
    11 exception.printStackTrace()
    12 println("Failed to delete the user: ${exception.message}")
    13 }
    14 }
    15 }.onFailure { exception ->
    show all 20 lines
  • deleteUser()

    1// reference the "chat" object and directly invoke the "deleteUser()" method
    2chat.deleteUser("support_agent_15").async { deleteResult ->
    3 deleteResult.onSuccess {
    4 // handle success
    5 println("User successfully deleted permanently.")
    6 }.onFailure { exception ->
    7 // handle failure
    8 exception.printStackTrace()
    9 println("Failed to delete the user: ${exception.message}")
    10 }
    11}
Last updated on