Delete users
Remove users with delete() or deleteUser(). Choose between permanent deletion or soft delete (preserving data in App Context storage).
delete()- call on aUserobject (no ID needed)deleteUser()- call on aChatobject (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()(on theUserobject)1user.delete(
2 soft: Bool = false
3) async throws -> UserImpl? -
deleteUser()(on theChatobject)1chat.deleteUser(
2 id: String,
3 soft: Bool = false
4) async throws -> UserImpl?
Input
| Parameter | Required in delete() | Required in deleteUser() | Description |
|---|---|---|---|
idType: StringDefault: n/a | No | Yes | Unique user identifier (up to 92 UTF-8 characters). |
softType: BoolDefault: false | No | No | Define if you want to permanently remove user metadata. The user metadata gets permanently deleted from the App Context storage by default. If you set this parameter to true, the User object gets the deleted status, and you can still restore/get their metadata. |
Output
| Parameter | Description |
|---|---|
UserImpl | For hard delete, the method returns nil. For soft delete, an updated user instance with the status field set to deleted. |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Permanently delete user support_agent_15.
-
delete()1 -
deleteUser()1
Other examples
Archive (soft delete) the user with an ID of support_agent_15, keeping their data in the App Context storage.
-
delete()1 -
deleteUser()1