Create a card message
Construct a contact business card message to share a user’s profile information.
Invoke createCardMessage() to produce a contact card message sharing a user's profile details. The embedded profile attributes represent a snapshot at creation time and do not update automatically if the target user modifies their profile later.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | string | Recommended | Stable user ID of the shared user profile. |
nickname | string | Recommended | Display name shown on the contact card. |
faceURL | string | No | Avatar URL for the shared contact. |
ex | string | No | Custom extension string; the SDK preserves this as an unparsed string. |
Code example
import { createCardMessage } from '@/uni_modules/unix-openim-sdk'
const message = await createCardMessage({
userID: 'user_42',
nickname: 'Alex',
faceURL: 'https://example.com/avatar/user_42.png',
ex: JSON.stringify({ source: 'team-directory' }),
})
if (message == null) returnWhile individual fields are typed as optional, constructing a meaningful card requires a valid userID and display name. When recipients initiate actions such as sending a friend request or opening a chat from a card, re-query user information through Get user profiles rather than treating card fields as live authorization credentials.
Return value
The Promise resolves with an OpenIMMessageItem | null object.
State changes after the call
Pass the constructed message item to Send a message. Track message status updates in your UI using clientMsgID.
Was this page helpful?