How to get user profile (non-user profile hosting version)

To display user profiles in your conversation list or history messages, query your user table using the Target ID.

Display in the conversation list

Get user profile via the App Server.

  1. Your App Server encapsulates the interface to fetch user or group profiles.
  2. Retrieve the User ID or Group ID from the conversation Target ID.
  3. Pass the User ID or Group ID to the App Server’s interface to get the corresponding profile.
  4. Display the profile on the page.
sequenceDiagram
    participant IMSDK as IMSDK
    participant App as App
    participant AppServer as AppServer

    IMSDK->>App: Return historical message list
    App-->>IMSDK: Call get historical messages method
    App-->>AppServer: Get sender user information by conversation.targetId
    AppServer->>App: Return user or group information for display

Display user profile in history messages

Method 1: Get user profile via the developer’s App Server

  1. The developer’s App Server encapsulates the interface to fetch user profiles.
  2. Retrieve the sender ID from message sender User ID.
  3. Pass the sender ID to the App Server’s interface to get the corresponding user profile.
  4. Display the user profile on the page.
sequenceDiagram
    participant IMSDK as IMSDK
    participant App as App
    participant AppServer as AppServer

    IMSDK->>App: Return historical message list
    App-->>IMSDK: Call get historical messages method
    App-->>AppServer: Get sender user information by message.senderUserId
    AppServer->>App: Return user information for display

Method 2: Embed user profile in the message

The embedded user profile is saved in the message. If the user updates their profile, the embedded profile in sent messages won’t sync.

  1. Fetch the current user’s (sender’s) profile.
  2. Embed the current user’s profile when sending the message.
  3. Display the profile from the Message Body when showing the message.