On this page

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 a User object (no ID needed)
  • updateUser() - call on a Chat object (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

ParameterRequired in update()Required in updateUser()Description
id
Type: String
Default:
n/a
No
Yes
Unique user identifier.
name
Type: String
Default:
n/a
No
No
Display name for the user (must not be empty or consist only of whitespace characters).
externalId
Type: String
Default:
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.
profileUrl
Type: String
Default:
n/a
No
No
URL of the user's profile picture.
email
Type: String
Default:
n/a
No
No
User's email address.
custom
Type: [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.
status
Type: String
Default:
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.
type
Type: String
Default:
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

ParameterDescription
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 changes

    1user.onUpdated(
    2 callback: @escaping (UserImpl) -> Void
    3) -> AutoCloseable
  • onDeleted() — closure called when the user is deleted

    1user.onDeleted(
    2 callback: @escaping () -> Void
    3) -> AutoCloseable
  • streamUpdatesOn() (static) — monitors multiple users

    1UserImpl.streamUpdatesOn(users: [UserImpl]) -> AsyncStream<[UserImpl]>

Input

* required
ParameterDescription
callback (in onUpdated) *
Type: (UserImpl) -> Void
Default:
n/a
Closure called with the updated user whenever its metadata changes.
callback (in onDeleted) *
Type: () -> Void
Default:
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

ParameterDescription
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.

1

Watch multiple users

Get updates on multiple user objects at once.

1

Last updated on