ZIM Upgrade Guide
This document describes notes and considerations when upgrading the ZIM Web SDK version.
3.1.0 Upgrade Guide
ZIM SDK 3.1.0 has added deprecation tags to some APIs. Please refer to the following instructions to complete the migration.
Newly deprecated APIs
queryGroupMessageReceiptReadMemberList and queryGroupMessageReceiptUnreadMemberList have been deprecated since version 3.1.0. To query the member list of group messages with read, unread (undelivered), or delivered status, use queryGroupMessageReceiptMemberList instead.
queryGroupMessageReceiptMemberList usage example
Parameter description:
| Parameter | Description |
|---|---|
| message | The message with receipt to query. |
| groupID | The group ID of the corresponding group conversation. |
| count | The number of users to query, up to 100 per query. |
| config | Query configuration: ZIMGroupMessageReceiptMemberQueryConfig, which can configure the query start marker nextFlag and the query item (read, unread [undelivered], delivered). |
| Result | Description |
|---|---|
| ZIMGroupMessageReceiptMemberListQueriedResult | Query result callback, where userList is the group member list matching the query conditions, and nextFlag is the start marker for the next query (when nextFlag is 0, the query is complete). |
Code example:
// 1. Create query configuration
const config = new ZIMGroupMessageReceiptMemberListQueryConfig();
config.nextFlag = 0; // Initially set to 0, then set to the nextFlag returned from the result
config.filterType = ZIMMessageReceiptFilterType.Read; // Default value, query read members
// 2. Call the API
zim.queryGroupMessageReceiptMemberList(message, groupID, 10, config)
.then((result) => {
// Query successful
// result.userList — List<ZIMGroupMemberInfo>, group member list matching the query conditions
// result.nextFlag — Start marker for the next query, 0 indicates query is complete
// result.groupID — Group ID
// result.errorInfo — ZIMError, code 0 indicates success
})
.catch((error) => {
// Query failed
});Upgrade Guide for 3.0.0
This version (3.0.0) removes some interfaces that have been deprecated for over a year, and adds deprecation markers to some events. Please refer to the following instructions to complete the migration.
Removed interfaces
ZIM initialization interface (create)
The deprecated legacy create(appID: number) interface has been removed. Please use the create interface that accepts a ZIMAppConfig parameter instead.
const appConfig: ZIMAppConfig = {
appID: 12345678,
appSign: 'appSign',
};
ZIM.create(appConfig);ZIM login interface (login)
The deprecated legacy login(userInfo: ZIMUserInfo, token: string) interface has been removed. Please use the login interface that accepts userID and a ZIMLoginConfig parameter instead.
const loginConfig: ZIMLoginConfig = {
userName: 'userName',
token: '', // If using Token authentication, fill in the Token
isOfflineLogin: false,
};
await zim.login('userID', loginConfig);ZIM message receive callback interface
The receivePeerMessage, receiveRoomMessage, and receiveGroupMessage events deprecated in 2.18.0 have been formally removed in this version. Migrate to messageReceived.
zim.on('messageReceived', (zim: ZIM, result: ZIMMessageReceivedEventResult) => {
const { messageList, info, conversationID, conversationType } = result;
// Handle messages of different conversation types based on conversationType
});ZIM call invitation callback interface
The legacy callInvitationRejected, callInvitationAccepted, and callInviteesAnsweredTimeout events have been removed. Please use the callUserStateChanged event instead. The callback parameters of the callInvitationTimeout event have also been updated with an additional ZIMCallInvitationTimeoutInfo parameter.
zim.on('callUserStateChanged', (zim: ZIM, result: ZIMCallUserStateChangedEventResult) => {
const { callUserList, callID } = result;
// callUserList contains the list of users whose state has changed
// Accept, reject, and timeout state changes can be handled uniformly
});importLocalMessages / exportLocalMessages interface removal
The importLocalMessages and exportLocalMessages interfaces have been temporarily removed in 3.0.0 with no replacement yet. This feature will be re-introduced in a later version. Please follow the SDK release notes for updates.
Newly deprecated interfaces (recommended migration)
ZIM message receive callback interface
The peerMessageReceived, roomMessageReceived, and groupMessageReceived events have been marked as deprecated in this version. They still work, but we recommend migrating to messageReceived as soon as possible.
zim.on('messageReceived', (zim: ZIM, result: ZIMMessageReceivedEventResult) => {
const { messageList, info, conversationID, conversationType } = result;
// Handle messages of different conversation types based on conversationType
});ZIMGroupConversation deprecation
ZIMGroupConversation has been deprecated in 3.0.0. The isDisabled and mutedExpiredTime fields should be replaced with the corresponding properties of the base class ZIMConversation:
| ZIMGroupConversation (deprecated) | ZIMConversation (replacement) |
|---|---|
isDisabled | isConversationDisabled |
mutedExpiredTime | selfMutedExpiredTime |
const isDisabled: boolean = conversation.isConversationDisabled;
const mutedExpiredTime: number = conversation.selfMutedExpiredTime;Field changes
ZIMConversationChangeInfo field change
The event property (of type ZIMConversationEvent) in ZIMConversationChangeInfo has been removed. Please use the action property (of type ZIMConversationChangeAction) in the same structure instead.
zim.on('conversationChanged', (zim: ZIM, result: ZIMConversationChangedEventResult) => {
result.infoList.forEach(changeInfo => {
const action: ZIMConversationChangeAction = changeInfo.action;
// Handle conversation changes based on action
});
});TypeScript interface rename
All TypeScript interfaces prefixed with ZIMEventOf in ZIMEventHandler.ts have been renamed according to a unified convention:
Naming rule: ZIMEventOf<Name>Result → ZIM<Name>EventResult
Typical examples:
| Legacy name | New name |
|---|---|
ZIMEventOfConversationMessageReceivedResult | ZIMConversationMessageReceivedEventResult |
ZIMEventOfCallInvitationRejectedResult | ZIMCallInvitationRejectedEventResult |
ZIMEventOfCallInvitationAcceptedResult | ZIMCallInvitationAcceptedEventResult |
ZIMEventOfCallInviteesAnsweredTimeoutResult | ZIMCallInviteesAnsweredTimeoutEventResult |
This change is transparent to most developers and requires no code modification. Reason: The callback parameter type of zim.on(eventName, callback) is automatically inferred by TypeScript based on the event name, no need to explicitly reference these interface names.
Only when you have explicitly annotated ZIMEventOf* type names in your code will TypeScript compilation errors occur. Just rename the types according to the table above.
Enum value rename
ZIMGroupMessageNotificationStatus
ZIMGroupMessageNotificationStatus.Disturb has been renamed to ZIMGroupMessageNotificationStatus.DoNotDisturb. Please check and replace all references in your code.
const status = ZIMGroupMessageNotificationStatus.DoNotDisturb;Upgrade Guide for 2.28.0
In ZIM SDK version 2.28.0, the timing of event callback triggering has been adjusted. Please read the following guide when upgrading from an older version to 2.28.0.
Changes to Event Callback Timing
messageReactionsChanged
The messageReactionsChanged event will now also be triggered on the client side after successfully calling addMessageReaction, deleteMessageReaction, or deleteMessageAllReactions. Please check whether your related business logic is affected after upgrading the SDK.
conversationChanged
The conversationChanged event will now also be triggered on the client side after successfully calling deleteConversation. Please check whether your related business logic is affected after upgrading the SDK.
conversationsAllDeleted
The conversationsAllDeleted event will now also be triggered on the client side after successfully calling deleteAllConversations. Please check whether your related business logic is affected after upgrading the SDK.
Upgrade Guide for 2.21.0
Starting from version 2.21.0, after WebSocket reconnects successfully, the SDK will no longer automatically rejoin previously joined rooms. Therefore, when upgrading from an older version to 2.21.0 and above, please read the following guide.
Handling Room Reconnection
If the SDK reconnects WebSocket due to background switch or network issues, it will not automatically rejoin rooms that have already been joined. Developers need to listen to both connectionStateChanged and roomStateChanged events and actively call enterRoom or joinRoom to rejoin rooms.
For detailed handling, refer to: ZIM Room Disconnection Handling.
Upgrade Guide for 2.19.0
Starting from version 2.19.0, the following interfaces have undergone major changes. Please read the following guide if you are upgrading from an older version to 2.19.0.
sendMediaMessage
Since version 2.19.0, you must use the sendMessage interface to send media messages. The sendMediaMessage interface is deprecated to unify message sending and facilitate future expansion.
In ZIMMessageSendNotification, the message parameter type of the onMediaUploadingProgress callback has changed from ZIMMessage to ZIMMediaMessage, ensuring only media messages trigger this callback. Typescript developers should fix their code according to IDE compilation errors. (Currently, only projects using Typescript and the replyMessage interface may be affected and need to resolve compilation errors.)
const imageMessage: ZIMMessage = {
type: 11,
fileLocalPath: File
}
const config: ZIMMessageSendConfig = {
priority: 1
}
// !mark
const notification: ZIMMessageSendNotification = {
onMessageAttached: (message: ZIMMessage) => {
// Developers can listen to this callback for actions before the message is sent
},
// !mark
onMessageUploadingProgress: (message: ZIMMediaMessage, currentFileSize: number, totalFileSize: number) => {
// Media upload progress
}
}
// !mark
zim.sendMessage(imageMessage, "TO_CONVERSATION_ID", 0, config, notification)
.then((res: ZIMMessageSentResult) => {
// Message sent result
})
.catch((errorInfo) => {
// Message send failed
})Upgrade Guide for 2.18.0
Starting from version 2.18.0, the following interfaces have undergone significant changes. Please read the following guide if you are upgrading from an older version to 2.18.0.
Peer-to-Peer Message Receiving Callback
The original peer message receiving callback receivePeerMessage is deprecated. Please use peerMessageReceived instead.
The new callback supports the following:
- When the user is online, you can receive online peer messages via this callback.
- After re-logging into the ZIM SDK, you can receive all peer messages sent during offline periods (up to 7 days).
// New Interface
peerMessageReceived: (zim: ZIM, data: ZIMEventOfConversationMessageReceivedResult) => void;
// Old Interface
receivePeerMessage: (zim: ZIM, data: ZIMEventOfReceiveConversationMessageResult) => void;Room Message Receiving Callback
The original room message receiving callback receiveRoomMessage is deprecated. Please use roomMessageReceived instead.
The new callback supports the following:
- When the user is online, you can receive room messages in real-time.
- When the user recovers from offline to online and is still in the room, lost room messages during the offline period will be received via this callback.
// New Interface
roomMessageReceived: (zim: ZIM, data: ZIMEventOfConversationMessageReceivedResult) => void;
// Old Interface
receiveRoomMessage: (zim: ZIM, data: ZIMEventOfReceiveConversationMessageResult) => void;Group Message Receiving Callback
The original group message receiving callback receiveGroupMessage is deprecated. Please use groupMessageReceived instead.
The new callback supports the following:
- When the user is online, you can receive online group messages via this callback.
- After re-logging into the ZIM SDK, you can receive all group messages sent during offline periods (up to 7 days).
// New Interface
groupMessageReceived: (zim: ZIM, data: ZIMEventOfConversationMessageReceivedResult) => void;
// Old Interface
receiveGroupMessage: (zim: ZIM, data: ZIMEventOfReceiveConversationMessageResult) => void;Upgrade Guide for 2.16.0
Starting from version 2.16.0, the following interfaces have undergone major changes. Please read the following guide if you are upgrading from an older version to 2.16.0.
callCancel
The following change only applies to advanced mode call invitations.
In the new callCancel version, if the userIDs parameter contains one or more userIDs, the interface will only cancel invitations sent to these specific users. If the userIDs parameter is empty, all pending invitations will be cancelled.
In older versions, the callCancel interface cancels invitations for all invitees regardless of whether the userIDs parameter is given or empty.
Since the old ZIM SDK does not support single invitation cancellation, if you need to keep both the cancellation logic of older versions and the single cancellation capability of the new version, please isolate the call feature between old and new ZIM versions.
// Cancel invitations to userIdA and userIdB specifically
const callID = 'xxxx';
const invitees = ['userIdA','userIdB']; // Invitee userID list
const config: ZIMCallCancelConfig = { extendedData: 'xxxx' };
zim.callCancel(invitees, callID, config)
.then((res: ZIMCallCancelSentResult) => {
// Operation successful
})
.catch((err: ZIMError) => {
// Operation failed
})
// Cancel the entire call invitation; succeeds only if all invitees have not accepted
const callID = 'xxxx';
const invitees = []; // Invitee userID list
const config: ZIMCallCancelConfig = { extendedData: 'xxxx' };
zim.callCancel(invitees, callID, config)
.then((res: ZIMCallCancelSentResult) => {
// Operation successful
})
.catch((err: ZIMError) => {
// Operation failed
})