Browse SDKs · iOS
Platform
SDKsiOS

Create an @ message

Create a text message that mentions specified group members with OpenIM iOS SDK.

Copy

Invoke createTextAtMessage:atUsersID:atUsersInfo:message: on OIMMessageInfo to construct a text message mentioning one or more specific group members:

Parameters

ParameterTypeRequiredDescription
textNSString *YesThe text content including @ mention display strings.
atUsersIDNSArray<NSString *> *YesList of user IDs corresponding to mentioned group members.
atUsersInfoNSArray<OIMAtInfo *> *YesList of display models providing member nicknames for UI rendering.
messageOIMMessageInfo * _NullableNoQuoted reference message; pass nil if no message is being quoted.

Code example

OIMAtInfo *info = [OIMAtInfo new];
info.atUserID = member.userID;
info.groupNickname = member.nickname;

OIMMessageInfo *message =
    [OIMMessageInfo createTextAtMessage:text
                              atUsersID:@[member.userID]
                            atUsersInfo:@[info]
                                message:nil];

Return value

Returns an initialized OIMMessageInfo model with its content type set to @ mention text.

State changes after the call

  1. Local memory instantiation: This method creates an in-memory object without writing to the database or triggering network requests.
  2. Subsequent dispatch: Deliver this message to a group conversation by calling Send a message.