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.
- Your App Server encapsulates the interface to fetch user or group profiles.
- Retrieve the User ID or Group ID from the conversation Target ID.
- Pass the User ID or Group ID to the App Server’s interface to get the corresponding profile.
- 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
- The developer’s App Server encapsulates the interface to fetch user profiles.
- Retrieve the sender ID from message sender User ID.
- Pass the sender ID to the App Server’s interface to get the corresponding user profile.
- 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.
- Fetch the current user’s (sender’s) profile.
- Embed the current user’s profile when sending the message.
- Display the profile from the Message Body when showing the message.