logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

ZIM upgrade Guide


This article provides some instructions and considerations for upgrading the ZIM SDK for React Native version.

2.19.0 upgrade guide

Warning

Starting from version 2.19.0, the following interfaces have undergone significant changes. Therefore, when upgrading from an older version to version 2.19.0, please read the following guidelines.

The original downloadMediaFile API is deprecated. Please use the new downloadMediaFile instead. The updated downloadMediaFile introduces a new config parameter, which can be used to specify the download of individual media content in multi-item messages.

In ZIMMediaDownloadingProgress and ZIMMediaDownloadedResult, the parameter message type has changed from ZIMMediaMessage to ZIMMessage to support composite messages. TypeScript developers need to update their code based on the compilation error messages from their IDE.

title="Usage
title="Usage
Old Usage
// Assume multipleMessage.messageInfoList[0] is a text message, and multipleMessage.messageInfoList[1] is an image message
const multipleMessage: ZIMMessageBase = {
    type: ZIMMessageType.Multiple,
    messageInfoList: [
        new ZIMTextMessageLiteInfo({
            text: "Hello, World!"
        }),
        new ZIMImageMessageLiteInfo({
            fileLocalPath: file
        })
    ]
}

const config: ZIMMediaDownloadConfig = {
    // Specify to download the image message
    messageInfoIndex: 1
}

zim.downloadMediaFile(multipleMessage, ZIMMediaFileType.OriginalFile, config, (message: ZIMMessage, currentFileSize: number, totalFileSize: number) => {
    // Download progress
    // Developers need to check the type of the message and cast it to the corresponding message type
    if (message.type === ZIMMessageType.Multiple) {
        const multipleMessage: ZIMMultipleMessage = message as ZIMMultipleMessage
        // Handle multi-item messages
    }
    // Handle other types of messages
    ......

}).then((message: ZIMMessage) => {
    // Download complete
    // Developers need to check the type of the message and cast it to the corresponding message type
    if (message.type === ZIMMessageType.Multiple) {
        const multipleMessage: ZIMMultipleMessage = message as ZIMMultipleMessage
        // Handle multi-item messages
    }
    // Handle other types of messages
    ......
}).catch((errorInfo: ZIMError) => {
    // Failed to download
})
1
Copied!
const imageMessage = new ZIMMessageBase({
    type: ZIMMessageType.Image,
    fileLocalPath: file
})

zim.downloadMediaFile(imageMessage, ZIMMediaFileType.OriginalFile, (message: ZIMMessage, currentFileSize: number, totalFileSize: number) => {
    // Download progress
    // Developers need to check the type of the message and cast it to the corresponding message type
    if (message.type === ZIMMessageType.Image) {
        const imageMessage = new ZIMImageMessage(message)
        // Handler image messages
    }
    // Handle other types of messages
    ......
}).then((message: ZIMMessage) => {
    // Download complete
    // Developers need to check the type of the message and cast it to the corresponding message type
    if (message.type === ZIMMessageType.Image) {
        const imageMessage = new ZIMImageMessage(message)
        // Handler image messages
    }
    // Handle other types of messages
    ......
}).catch((errorInfo: ZIMError) => {
    // Failed to download
})
1
Copied!
const imageMessage = new ZIMMessageBase({
    type: ZIMMessageType.Image,
    fileLocalPath: file
})

zim.downloadMediaFile(imageMessage, ZIMMediaFileType.OriginalFile, (message: ZIMMediaMessage, currentFileSize: number, totalFileSize: number) => {
    // Download progress
}).then((message: ZIMMediaMessage) => {
    // Download complete
}).catch((errorInfo: ZIMError) => {
    // Failed to download
})
1
Copied!

In ZIMMessageSendNotification, the message parameter type in the onMediaUploadingProgress callback method has changed from ZIMMessage to ZIMMediaMessage to ensure that only media messages are notified in the callback. TypeScript developers need to fix the calls based on the compile error hints from the IDE. (Currently, only developers using TypeScript and the replyMessage interface will be affected by the need to resolve compile errors.)

Usage in Version 2.19.0
Old Usage
const imageMessage: ZIMMessageBase = {
    type: ZIMMessageType.Image,
    fileLocalPath: file
}

const config: ZIMMessageSendConfig = {
    priority: ZIMMessagePriority.Medium
}

const notification: ZIMMessageSendNotification = {
    onMessageAttached: (message: ZIMMessage) => {
        // Developers can listen to this callback to execute business logic before sending the message
    },
    onMessageUploadingProgress: (message: ZIMMediaMessage, currentFileSize: number, totalFileSize: number) => {
        // Multimedia upload progress
    }
}

zim.sendMessage(imageMessage, "TO_CONVERSATION_ID", ZIMConversationType.Peer, config, notification).then((message: ZIMMessage) => {
    // Message send result
}).catch((errorInfo: ZIMError) => {
    // Message send failed
})
1
Copied!
const imageMessage: ZIMMessageBase = {
    type: ZIMMessageType.Image,
    fileLocalPath: file
}

const config: ZIMMessageSendConfig = {
    priority: ZIMMessagePriority.Medium
}

const notification: ZIMMediaMessageSendNotification = {
    onMessageAttached: (message: ZIMMediaMessage) => {
        // Developers can listen to this callback to execute business logic before sending the message

    },
    onMessageUploadingProgress: (message: ZIMMediaMessage, currentFileSize: number, totalFileSize: number) => {
        // Multimedia upload progress
    }
}

zim.sendMediaMessage(imageMessage, "TO_CONVERSATION_ID", ZIMConversationType.Peer, config, notification).then((message: ZIMMessage) => {
    // Message send result
}).catch((errorInfo: ZIMError) => {
    // Message send failed
})
1
Copied!

2.18.0 upgrade guide

Warning

Starting from version 2.18.0, the following interfaces have undergone significant changes. Therefore, when upgrading from an older version to version 2.18.0, please read the following guidelines.

Callback on receiving one-to-one messages

The deprecated callback receivePeerMessage for receiving one-to-one messages has been replaced by peerMessageReceived.

The new callback supports the following features:

  • When a user is online, they can receive one-to-one messages through this callback.
  • When a user logs back into the ZIM SDK, they can receive all one-to-one messages received during their offline period (up to 7 days).
Untitled
// New callback
peerMessageReceived: (zim: ZIM, data: ZIMEventOfConversationMessageReceivedResult) => void;

// Old callback
receivePeerMessage: (zim: ZIM, data: ZIMEventOfReceiveConversationMessageResult) => void;
1
Copied!

Callback on receiving room messages

The deprecated callback receiveRoomMessage for receiving room messages has been replaced by roomMessageReceived.

The new callback supports the following features:

  • When a user is online, they can receive online room messages through this callback.
  • When a user goes from offline to online and is still in the room, they can receive all room messages that were sent during their offline period through this callback.
Untitled
// New callback
roomMessageReceived: (zim: ZIM, data: ZIMEventOfConversationMessageReceivedResult) => void;

// Old callback
receiveRoomMessage: (zim: ZIM, data: ZIMEventOfReceiveConversationMessageResult) => void;
1
Copied!

Callback on receiving group messages

The deprecated callback receiveGroupMessage for receiving group messages has been replaced by groupMessageReceived.

The new callback supports the following features:

  • When the user is online, they can receive online group messages through this callback.
  • When the user logs back into the ZIM SDK, they can receive all group chat messages received during the offline period (up to 7 days) through this callback.
Untitled
// New callback
groupMessageReceived: (zim: ZIM, data: ZIMEventOfConversationMessageReceivedResult) => void;


// Old callback
receiveGroupMessage: (zim: ZIM, data: ZIMEventOfReceiveConversationMessageResult) => void;
1
Copied!

2.16.0 Upgrade Guide

Warning

Starting from version 2.16.0, there are significant changes to the following interfaces. Therefore, when upgrading from an older version to version 2.16.0, please read the following guide.

callCancel

Note

The following changes only apply to advanced mode call invitations.

In the new version of callCancel, if the parameter userIDs contains a userID, this interface will only cancel the invitation for that callee. If the userIDs parameter is empty, this interface will cancel the invitation for all callees.

For the old version of the callCancel interface, regardless of whether the userIDs parameter is empty or not, it is considered as canceling the invitation for all callees.

Since the old version of the ZIM SDK is not compatible with separate cancellation logic, if you need to retain the cancellation logic implemented using the old version of ZIM and also need to use the separate cancellation feature of the new version, please isolate the call functionality between the old and new versions of ZIM.

Usage in version 2.16.0
Usage in old versions
// Cancel userIdA and userIdB separately
var callID = 'xxxx';
var invitees = ['userIdA','userIdB'];  // List of invitees' IDs
var config = { extendedData: 'xxxx' }; 
zim.callCancel(invitees, callID, config)
    .then(res => {
          // Operation successful
    })
    .catch(err => {
        // Operation failed
    })

// Cancel the entire call invitation, can be called successfully when none of the callees in the call have accepted    
var callID = 'xxxx';
var invitees = [];  // List of invitees' IDs
var config = { extendedData: 'xxxx' }; 
zim.callCancel(invitees, callID, config)
    .then(res => {
          // Operation successful
    })
    .catch(err => {
        // Operation failed
    })
1
Copied!
// Regardless of whether userID is passed in userIDs, it is considered as canceling the entire call, can be called successfully when none of the callees in the call have accepted
var callID = 'xxxx';
var invitees = ['userIdA','userIdB'];  // List of invitees' IDs
var config = { extendedData: 'xxxx' }; 
zim.callCancel(invitees, callID, config)
    .then(res => {
          // Operation successful
    })
    .catch(err => {
        // Operation failed
    })

// Cancel the entire call invitation, can be called successfully when none of the callees in the call have accepted    
var callID = 'xxxx';
var invitees = [];  // List of invitees' IDs
var config = { extendedData: 'xxxx' }; 
zim.callCancel(invitees, callID, config)
    .then(res => {
          // Operation successful
    })
    .catch(err => {
        // Operation failed
    })
1
Copied!

Previous

ZIM Audio release notes

Next

ZPNs upgrade guide