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

Create an @ message

OpenIM uni-app / uni-app x SDK guide for Create an @ message.

Copy

Parameters

ParameterTypeRequiredDescription
textstringYesMessage text; use stable @userID markers.
atUserIDListstring[]YesMentioned users; obtain the special tag from getAtAllTag() for everyone.
atUsersInfoOpenIMAtUsersInfoItem[] or nullNoUser IDs and group display names.
quoteMessageOpenIMMessageItem or nullNoOriginal quoted message.
import { createTextAtMessage } from '@/uni_modules/unix-openim-sdk'

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

The Promise creates OpenIMMessageItem | null. This message can only be sent to a group. Keep atUserIDList aligned with atUsersInfo; creation does not change conversation mention state or emit events.

Mention everyone

Do not hard-code the everyone tag. Obtain the deployed value from commercial getAtAllTag() Commercial, then place it in both the text and ID list:

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

const atAllResult = await getAtAllTag()
const atAllTag = atAllResult?.tag
if (atAllTag != null) {
  const message = await createTextAtMessage({
    text: `${atAllTag} please read the announcement`,
    atUserIDList: [atAllTag],
  })
}

getAtAllTag() only reads the convention. Send the created message separately with the target group ID.