Manage user updates
Update user details and receive real-time update events.
Requires App Context
Enable App Context in the Admin Portal to store user data.
Update user details
Edit user metadata with update() or updateUser().
update()- call on aUserobject (no ID needed)updateUser()- call on aChatobject (requires user ID)
Method signature
These methods take the following parameters:
-
update()1user.update(
2 name: String? = nil,
3 externalId: String? = nil,
4 profileUrl: String? = nil,
5 email: String? = nil,
6 custom: [String: JSONCodableScalar]? = nil,
7 status: String? = nil,
8 type: String? = nil
9) async throws -> UserImpl -
updateUser()1chat.updateUser(
2 id: String,
3 name: String? = nil,
4 externalId: String? = nil,
5 profileUrl: String? = nil,
6 email: String? = nil,
7 custom: [String: JSONCodableScalar]? = nil,
8 status: String? = nil,
9 type: String? = nil
10) async throws -> UserImpl
Input
| Parameter | Required in update() | Required in updateUser() | Description |
|---|---|---|---|
idType: StringDefault: n/a | No | Yes | Unique user identifier. |
nameType: StringDefault: n/a | No | No | Display name for the user (must not be empty or consist only of whitespace characters). |
externalIdType: StringDefault: n/a | No | No | User's identifier in an external system. You can use it to match id with a similar identifier from an external database. |
profileUrlType: StringDefault: n/a | No | No | URL of the user's profile picture. |
emailType: StringDefault: n/a | No | No | User's email address. |
customType: [String: JSONCondableScalar]Default: n/a | No | No | JSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported. Filtering App Context data through the custom property is not recommended in SDKs. |
statusType: StringDefault: n/a | No | No | Tag that lets you categorize your app users by their current state. The tag choice is entirely up to you and depends on your use case. For example, you can use status to mark users in your chat app as invited, active, or archived. |
typeType: StringDefault: n/a | No | No | Tag that lets you categorize your app users by their functional roles. The tag choice is entirely up to you and depends on your use case. For example, you can use type to group users by their roles in your app, such as moderator, player, or support-agent. |
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Output
| Parameter | Description |
|---|---|
UserImpl | Returned object containing the updated user metadata. |
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.
Change the link to the user's support_agent_15 LinkedIn profile to https://www.linkedin.com/mkelly_vp2.
-
update()1 -
updateUser()1
Get user updates
Receive updates when User objects are edited or removed:
streamUpdates()- monitors a single userstreamUpdatesOn()- monitors multiple users
Callback behavior
streamUpdates(): returns updatedUserobject (ornilif deleted)streamUpdatesOn(): returns complete list of monitored users on any change
Method signature
These methods take the following parameters:
-
streamUpdates()1user.streamUpdates() -> AsyncStream<UserImpl?> -
streamUpdatesOn()(static)1UserImpl.streamUpdatesOn(users: [UserImpl]) -> AsyncStream<[UserImpl]>
Input
| Parameter | Required in streamUpdates() | Required in streamUpdatesOn() | Description |
|---|---|---|---|
usersType: [UserImpl]Default: n/a | No | Yes | A collection of UserImpl objects for which you want to get updates. |
Output
An asynchronous stream that produces updates when the underlying user(s) change.
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.
Get updates on support_agent_15.
-
streamUpdates()- AsyncStream
- Closure
11
Get updates on support_agent_15 and support_manager.
-
streamUpdatesOn()- AsyncStream
- Closure
11