getTotalUnreadMsgCount
Feature Introduction
Note
Get the total unread count of all conversations.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<dynamic> getTotalUnreadMsgCount({
String? operationID,
})
Input Parameters
None
Return Value
Name | Type | Description |
---|---|---|
~ | dynamic | Successful Return |
Code Sample
final count = await OpenIM.iMManager.conversationManager.getTotalUnreadMsgCount();
//todo
Function Prototype
- (void)getTotalUnreadMsgCountWithOnSuccess:(nullable OIMNumberCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
None
Return Value
Name | Type | Description |
---|---|---|
onSuccess | OIMNumberCallback | Successful Return |
onFailure | OIMFailureCallback | Failed Return |
Code Sample
[OIMManager.manager getTotalUnreadMsgCountWithOnSuccess:^(NSInteger number) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void getTotalUnreadMsgCount(OnBase<String> base)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
base | OnBase<String> | Yes | Callback Interface |
Code Sample
OpenIMClient.getInstance().conversationManager.getTotalUnreadMsgCount(new OnBase<String>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(String data) {
}
});
Function Prototype
IMSDK.getTotalUnreadMsgCount(operationID?: string): Promise<WsResponse<number>>
Input Parameters
None
Return Value
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<number>> | Successful Callback |
Promise.catch() | Promise<WsResponse> | Failed Callback |
Code Sample
import { getSDK } from '@openim/wasm-client-sdk';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { getSDK } from '@openim/client-sdk';
// const IMSDK = getSDK();
IMSDK.getTotalUnreadMsgCount()
.then(({ data }) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('getTotalUnreadMsgCount', operationID: string): Promise<number>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for troubleshooting, should be unique, recommended to use current time and random number |
Return Value
Using the
openim-uniapp-polyfill
package makes the function Promise-based. When calling, usethen
andcatch
to determine and handle successful and failed callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<number> | Successful Callback |
Promise.catch() | Promise<CatchResponse> | Failed Callback |
Code Sample
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('getTotalUnreadMsgCount', IMSDK.uuid())
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.getTotalUnreadMsgCount(operationID: string): Promise<number>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<number> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.getTotalUnreadMsgCount('operationID')
.then((data) => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});