Tutorial: FAQs (Web & Mini Program)

FAQs (Web & Mini Program)

FAQs (Web & Mini Program)


Documentation

1. Is there any online demo or SDK manual?

Mini program demo Mini program demo

Web demo

SDK manual

2. Where can I see the changes of the Mini Program SDK?

Update Log (Web & Mini Program)

3. Is the documentation of WebIM v1.7.x offline?

The documentation of WebIM v1.7.x has been deleted from the official website and is backed up on GitHub.


Framework Integration

1. Why can't I log in when I use zone.js to develop the project with Angular and integrate WebIM v2.x? System message: 'The error code (code) and error message (message) must be specified in IMPromise.reject`.

Modifying the prototype chain in zone.js of the Angular framework resulted in an error in the SDK integration. This problem has been fixed. Please use v2.1.4 or later.

2. Why can't I receive the TIM.EVENT.SDK_READY event when I use Taro to develop projects and integrate WebIM v2.x?

WebIM v2.x does not need to be compiled by Taro. If you have integrated WebIM through npm i, manually copy and paste the node_modules/tim-js-sdk/tim-js.js or node_modules/tim-wx-sdk/tim-wx.js file to the src directory of your project and configure the file in the configuration file (for more information, see Compilation Configuration Details). The following is an example:

weapp: {
  compile: {
    exclude: ['src/tencent-webim/tim-wx.js']
  }
}

Event Listening

1. Why can I still receive events distributed by the SDK after I call the off API to cancel event listening?

For the same event, such as TIM.EVENT.MESSAGE_RECEIVED, you need to ensure that the handler parameter points to the same function when you call the on API to enable event listening and call the off API to cancel event listening. Avoid the following writing:

// Attention! The following code is buggy and cannot cancel listening for the TIM.EVENT.MESSAGE_RECEIVED event because the bind() method returns a new function each time.
tim.on(TIM.EVENT.MESSAGE_RECEIVED, this.onMessageReceived.bind(this));
tim.off(TIM.EVENT.MESSAGE_RECEIVED, this.onMessageReceived.bind(this));
// Recommended writing
tim.on(TIM.EVENT.MESSAGE_RECEIVED, onMessageReceived, this);
tim.off(TIM.EVENT.MESSAGE_RECEIVED, onMessageReceived);

For more information on the bind() method, please see Function.prototype.bind().

2. If I call the logout API, will the SDK automatically cancel listening for events that the access side has listened for by calling the on API?

No. The access side needs to proactively call the off API to cancel event listening.


Login

1. Why the Err_TLS_Third_Sig_Check_Session_Key_Too_Long message is displayed during login?

Authenticating the generated UserSig failed due to a key problem. For more information, please see the official document Generating UserSig.

2. Why the "TypeError: wx.$app.ready is not a function" message is displayed during login?

Please listen for the TIM.EVENT.SDK_READY event instead of directly using the `ready` function, which has been disused.

3. Why can't I send a message after I log in successfully, and the system prompts that the API call time is unreasonable?

Please listen for the TIM.EVENT.SDK_READY event, and after the SDK is ready, call APIs that require authentication, such as the message sending API.


Message Receiving/Sending

1. From which version does the Mini Program support voice message sending? And which version for video messages?

Voice message sending is supported from v2.1.1, and voice and video message sending is supported from v2.2.0.

2. Why does WebIM v1.7.x occasionally encounter the failure to play voice messages?

You are advised to use WebIM v2.2.0 or later, which is compatible with voice and file messages sent by Native IM v3.x. WebIM v1.7.x has some issues. If the upgrade cannot be performed in a short time, please modify the WebIM v1.7.x code: about the message structure returned by the IM backend, when the value of Download_Flag is 0, the client gets the URL through UUID; when the value of Download_Flag is 2, the client can directly use the URL.

// WebIM v1.7.x code
Msg.Elem.Sound = function (uuid, second, size, senderId, receiverId, downFlag, chatType, url) {
  this.uuid = uuid; //File ID
  this.second = second; //Duration, in seconds
  this.size = size; //Size, in bytes
  this.senderId = senderId; //Sender
  this.receiverId = receiverId; //Recipient's ID
  this.downFlag = downFlag; //Download flag bit
  this.busiId = chatType == SESSION_TYPE.C2C ? 2 : 1; //busi_id (1: group conversation; 2: C2C conversation)
  if (downFlag == 0) {
    this.downUrl = getSoundDownUrl(uuid, senderId, second); //Download URL
  } else if (downFlag == 2 && url != null) {
    this.downUrl = url;
  }
}

3. How does WebIM v2.x pull historical messages? Is there no getC2CHistoryMsgs API?

WebIM v2.x does not provide the getC2CHistoryMsgs API. Instead, the getMessageList API can be used to "pull historical messages".

4. What should I do if I want to implement the like and gift giving features in audio-video groups?

Call the createCustomMessage or sendMessage API.

5. I have used the latest version of WebIM but why can't the video messages sent by the terminal be played on the iOS browser?

Please upgrade your TUIKit to v4.5.111 or later.

6. My project uses React. Why does sending image messages always fail?

Please upgrade your SDK to v2.0.11 or later.

7. Are WebIM v2.x and WebIM v1.7.x messages compatible with each other?

Yes. If conditions permit, you are advised to use the latest WebIM for better experience and maintenance.

8. How is WebIM v2.x compatible with the combined messages sent by RESTful APIs or IM SDKs of earlier versions?

Please upgrade your SDK to v2.1.3 or later. The content of combined messages is stored in the _elements property, and the access side needs to parse it. For more parsing details, see Message Formats. For non-combined messages, you are advised to use the type and payload properties of the Message instance.

9. Why can't I receive the TIM.EVENT.MESSAGE_RECEIVED event after I successfully send messages via the sendMessage API of WebIM v2.x?

When the sendMessage API returns Promise, the access side needs to call Promise.then or Promise.catch to process the business logic after message sending success or failure. In this case, the SDK does not distribute the TIM.EVENT.MESSAGE_RECEIVED event, avoiding message duplication.

10. Why are messages sometimes out of order when the message list pulled by getMessageList is combined with the messages received by listening for the TIM.EVENT.MESSAGE_RECEIVED event?

When maintaining the message list of a conversation on the access side, please ensure that the message listing order is correct. If the message list is arranged from old to new, the historical messages pulled through getMessageList should be listed from the head, and the real-time messages received by listening for the TIM.EVENT.MESSAGE_RECEIVED event should be listed from the tail.


Group

1. Why can't I receive messages after I create an audio-video group via the createGroup API?

After creating an audio-video group via the createGroup API, you need to call the joinGroup API to join the group (carrying the type TIM.TYPES.GRP_AVCHATROOM in the request) to enable the messaging process.

let promise = tim.joinGroup({ groupID: 'group1', type: TIM.TYPES.GRP_AVCHATROOM });
promise.then(function(imResponse) {
  switch (imResponse.data.status) {
    case TIM.TYPES.JOIN_STATUS_WAIT_APPROVAL: // Waiting to be approved by the admin
      break;
    case TIM.TYPES.JOIN_STATUS_SUCCESS: // Joined the group successfully
      console.log(imResponse.data.group); // Profile of the group
      break;
    case TIM.TYPES.JOIN_STATUS_ALREADY_IN_GROUP: // The user is already in the group
      break;
    default:
      break;
    }
  }).catch(function(imError){
    console.warn('joinGroup error:', imError); // Error information
});

2. Why is there no unread message count for audio-video groups? Why can't I pull historical messages?

The product policy is as follows: audio-video groups do not support counting unread messages or viewing historical messages before group joining. For more information, please see Group System.

3. Can I join two or more audio-video groups at the same time?

No at the moment. A user can only join one audio-video group at a time. For example, if a user is already in audio-video group A and attempts to join audio-video group B, the SDK will remove the user from audio-video group A first and then add the user to audio-video group B. For more information, please see joinGroup.

4. When I get the list of groups, can I also get the number of group members and other information of each group? Currently, you can only get the group type, group name, group profile photo, etc.

Yes. Please upgrade your SDK to v2.1.2 or later. For more information, please see getGroupList.