SDKsuni-app
Create a contact card message
OpenIM uni-app / uni-app x SDK guide for Create a contact card message.
Parameters
createCardMessage() accepts OpenIMCardElem. Its fields are nullable in the contract, but a useful card should provide a complete snapshot:
| Parameter | Type | Recommendation | Description |
|---|---|---|---|
userID | string or null | Required | User represented by the card. |
nickname | string or null | Required | Display name snapshot. |
faceURL | string or null | Required | Avatar URL snapshot. |
ex | string or null | Required | Extension data; use an empty string when unused. |
import { createCardMessage } from '@/uni_modules/unix-openim-sdk'
const message = await createCardMessage({
userID: 'user_b',
nickname: 'Alex',
faceURL: 'https://example.com/avatar.png',
ex: '',
})The Promise creates OpenIMMessageItem | null and does not send it. A card is a send-time snapshot and does not track profile changes. Resolve current data by userID when opened, and never treat card fields as authenticated identity.
Was this page helpful?