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: JSONCodableScalar]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 real-time updates when a User object is edited with onUpdated(), or be notified when it is deleted with onDeleted().
You can also use user.stream.updates() and user.stream.deletions() for AsyncStream-based equivalents.
For monitoring multiple users at once, streamUpdatesOn() remains available.
Deprecation
streamUpdates() is deprecated. Use onUpdated() and onDeleted() (closure-based) or user.stream.updates() and user.stream.deletions() (AsyncStream-based) instead.
Method signature
-
onUpdated()— closure called when the user metadata changes1user.onUpdated(
2 callback: @escaping (UserImpl) -> Void
3) -> AutoCloseable -
onDeleted()— closure called when the user is deleted1user.onDeleted(
2 callback: @escaping () -> Void
3) -> AutoCloseable -
streamUpdatesOn()(static) — monitors multiple users1UserImpl.streamUpdatesOn(users: [UserImpl]) -> AsyncStream<[UserImpl]>
Input
| Parameter | Description |
|---|---|
callback (in onUpdated) *Type: (UserImpl) -> VoidDefault: n/a | Closure called with the updated user whenever its metadata changes. |
callback (in onDeleted) *Type: () -> VoidDefault: n/a | Closure called when the user is deleted. |
users (in streamUpdatesOn) *Type: [UserImpl]Default: n/a | A collection of UserImpl objects for which you want to get updates. |
Output
| Parameter | Description |
|---|---|
AutoCloseable | An object you must retain. When released or closed, the listener stops. |
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.
- Closure
- AsyncStream
1
1
Watch multiple users
Get updates on multiple user objects at once.
- Closure
- AsyncStream
1
1