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

Add a user to the blacklist

Block a specified user by adding them to the authenticated account’s blacklist.

Copy

Invoke addBlack() to add a target user to the current account's blacklist.

Parameters

ParameterTypeRequiredDescription
toUserIDstringYesThe user ID of the target user to block.
exstringNoOptional business extension string.

Code example

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

await addBlack({
  toUserID,
  ex: JSON.stringify({ source: 'profile' }),
})

Return value

The Promise resolves with void once OpenIMServer processes the blacklist operation.

State changes after the call

A resolved Promise confirms that the request succeeded on OpenIMServer; it does not indicate that the onBlackAdded event has arrived across all devices. Upon receiving the event, merge the new record into local state using userID. To calibrate state, re-query the blacklist via Get the blacklist. Handle errors like duplicate blocking or permission errors via the rejected Promise.