WuKongIM Docs

HarmonyOS API reference

Find common @wukong/wkim entry points, providers, listeners, models, and states by manager.

This page is a quick lookup. Return to each task page for complete usage and call order. The SDK singleton is WKIM.shared.

Imports and initialization

The package root exports only WKIM:

import { WKIM } from '@wukong/wkim'

Import models and constants from @wukong/wkim/src/main/ets/entity/Bean, and payloads from @wukong/wkim/src/main/ets/model/....

APIPurpose
init(uid, token, address?, context?)Configure the user and open that UID's local database
config.providerApplication implementations for routing, sync, metadata, and upload
connectionManager()Connection and state
messageManager()Message sending, receiving, and queries
conversationManager()Conversation list and unread counts
channelManager()User and group metadata
channelMemberManager()Group-member metadata

Common providers

FieldPurpose
connectAddrCallbackReturn a dynamic host:port
syncConversationCallbackSynchronize conversations, recent messages, and unread counts
syncMessageCallbackSynchronize history for one channel
channelInfoCallbackFetch user or group metadata
channelMemberCallbackIncrementally synchronize group members
channelMemberWithPageCallbackPage or search group members
uploadAttachmentCallbackUpload media and set its URL

Providers are process-global fields; assigning one again replaces its previous implementation.

ConnectionManager

APIPurpose
connection()Start connecting
disConnection(false)Disconnect while retaining the current account
disConnection(true)Log out and close the local database
addConnectStatusListener(listener)Observe connection state
removeConnectStatusListener(listener)Remove it with the same function object

States: fail, success, kicked, syncing, connecting, noNetwork, and syncCompleted.

MessageManager

APIPurpose
send(content, channel)Send with default options
sendWithOption(content, channel, options)Send with custom options
addInsertedListenerObserve local insertion; one global callback
addSendStatusListenerObserve the server send result
addNewMsgListenerObserve new messages
addRefreshListenerObserve message-object changes
getOrSyncHistoryMessagesRead local history and synchronize when needed
registerMsgContentRegister a custom payload

Send states are WKSendMsgResult.loading, success, and fail, plus relationship restrictions noRelation, blackList, and notOnWhiteList.

ConversationManager

APIPurpose
all()Read all local conversations
getWithChannelRead one channel's conversation
updateRedDotUpdate an unread count
clearAllRedDotClear all unread counts
deleteRemove a local conversation-list item
addRefreshListenerObserve conversation changes
addDeletedListenerObserve conversation deletion

Channel and member managers

APIPurpose
channelManager().getChannelRead local channel metadata
channelManager().fetchChannelInfoRequest a metadata refresh
channelManager().addRefreshListenerObserve metadata changes
channelMemberManager().syncIncrementally synchronize members
channelMemberManager().getMemberRead one member
channelMemberManager().getWithPageOrSearchPage or search members

Common models

TypeMeaning
WKChannelchannelId and channelType together identify a chat target
WKMsgMessage identity, payload, sequence, and send state
WKMessageContentBase class for message payloads
WKTextContent / WKImageContentBuilt-in text and image payloads
WKConversationA conversation-list item and unread count
WKSyncConversation / WKSyncChannelMsgSync results returned from your API to the SDK
WKSendOptions / ChannelMsgOptions / SyncOptionsSend, history-query, and remote-sync options

Common channel types are WKChannelType.personal and WKChannelType.group.

On this page