SDKsHarmonyOSEnterprise
Create business card message
Create a contact card message to share user identity and profile information.
Contact card data is captured at the time the message is created and does not automatically update when user profile attributes change later.
Code example
import sdk, { CreateCardMessageReq, CreateCardMessageResp } from '@openimsdk/imsdk';
const request: CreateCardMessageReq = {
userID: 'user_42',
nickname: 'Alex',
faceURL: 'https://example.com/avatar/user_42.png',
ex: JSON.stringify({ source: 'team-directory' }),
};
const response: CreateCardMessageResp = await sdk.createCardMessage(request);
const message = response.message;Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | string | Yes | Target user ID represented by the contact card. |
nickname | string | Yes | Display nickname captured at creation time. |
faceURL | string | Yes | Avatar URL captured at creation time. |
ex | string | Yes | Custom extension string. |
Return value
Returns a Promise resolving to CreateCardMessageResp:
| Property | Type | Description |
|---|---|---|
message | IMMessage | Locally instantiated business card message object. |
State changes after the call
All four fields are required. Before initiating friend requests or starting conversations from a card, receiving clients should query the latest user profile and verify permissions rather than treating card fields as live identity credentials. This operation instantiates the message object locally; call Send message to dispatch it.
Was this page helpful?