Browse SDKs · uni-app / uni-app x
Platform
SDKsuni-app / uni-app x

Create an @ message

Construct an @ mention text message for group conversations.

Copy

Invoke createTextAtMessage() to create an @ mention text message for group chats. Keep the visible text in text synchronized with the identifiers listed in atUserIDList, using stable user IDs rather than nicknames to track mentioned members.

Parameters

ParameterTypeRequiredDescription
textstringYesMessage text content including @ display text.
atUserIDListstring[]YesArray of mentioned user IDs or the mention-all tag token.
atUsersInfoOpenIMAtUsersInfoItem[]NoArray of objects mapping user IDs to their group nicknames.
quoteMessageOpenIMMessageItemNoOriginal message to quote if creating a combined mention-and-reply message.

Code example

import { createTextAtMessage } from '@/uni_modules/unix-openim-sdk'

const message = await createTextAtMessage({
  text: '@Alex please review',
  atUserIDList: ['user_a'],
  atUsersInfo: [{
    atUserID: 'user_a',
    groupNickname: 'Alex',
  }],
})
if (message == null) return

Mention all group members

Never hardcode the mention-all string in application logic. Invoke getAtAllTag() to retrieve the authoritative token configured for your SDK, and place result.tag into both text and atUserIDList:

import {
  createTextAtMessage,
  getAtAllTag,
} from '@/uni_modules/unix-openim-sdk'

const result = await getAtAllTag()
if (result == null || result.tag.length == 0) return

const message = await createTextAtMessage({
  text: result.tag + ' Please review the announcement',
  atUserIDList: [result.tag],
})

getAtAllTag() retrieves the tag token only; it does not construct or transmit messages.

Return value

The Promise resolves with an OpenIMMessageItem | null object.

State changes after the call

Creating an @ message generates a local object without triggering new message events or altering conversation unread counters. Pass the created message to Send a message, specifying the target groupID. Track the message lifecycle in your UI state using clientMsgID.