SDKsAndroid
Create a contact card message
Use createCardMessage to create a contact card message.
Construct a personal contact card message to share user profiles with other chat participants. Use CardElem to package the target user's userID, nickname, and avatar URL.
Code example
CardElem cardElem = new CardElem();
cardElem.setUserID("user_target");
cardElem.setNickname("Li Si");
cardElem.setFaceURL("https://example.com/avatar.png");
Message message = OpenIMClient.getInstance().messageManager.createCardMessage(cardElem);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cardElem | CardElem | Yes | Contact card data model. Must specify the target user's ID userID, display name nickname, and avatar URL faceURL. |
Return value
Returns the created Message object with contentType set to MessageType.CARD.
State changes after the call
- Local initialization: Initializes the local
Messagestructure without sending data to the server or verifying user existence. - Transmission: Call Send a message to deliver the card message to a single user or group.
Was this page helpful?