SDKsiOS
Create a contact-card message
Create a user contact-card message with OpenIM iOS SDK.
Invoke createCardMessage: on OIMMessageInfo to construct a contact-card message object that recommends a user profile to the counterparty:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cardElem | OIMCardElem * | Yes | Contact-card element model containing recommended user attributes. |
Properties of OIMCardElem
| Parameter | Type | Required | Description |
|---|---|---|---|
userID | NSString * | Yes | User ID of the recommended contact. |
nickname | NSString * | No | Display nickname of the recommended contact snapshot. |
faceURL | NSString * | No | Avatar URL of the recommended contact snapshot. |
ex | NSString * | No | Custom business extension string. |
Code example
OIMCardElem *card = [OIMCardElem new];
card.userID = @"user_b";
card.nickname = @"Alex";
card.faceURL = @"https://example.com/avatar.png";
card.ex = @"";
OIMMessageInfo *message = [OIMMessageInfo createCardMessage:card];Return value
Returns an initialized OIMMessageInfo model with its content type set to contact card.
State changes after the call
- Local memory instantiation: This method constructs an in-memory message object without writing to the database or initiating network requests.
- Snapshot nature: The nickname and avatar inside the card element are snapshot values at message creation time. Subsequent updates to the user's profile will not automatically mutate historical card messages.
- Subsequent dispatch: Call Send a message to deliver the card message.
Was this page helpful?