subscribeUsersStatus
Feature Introduction
Description
Subscribe to the online status of specified users and return the online status of these users.
Note
The number of subscriptions per user cannot exceed 3000. If it exceeds, they will be eliminated based on the subscription time.
Related Callback: onUserStatusChanged
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<List<UserStatusInfo>> subscribeUsersStatus(
List<String> userIDs, {
String? operationID,
})
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDs | List<String> | Yes | List of user IDs |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
then | List<UserStatusInfo > | Successful callback |
onError | Function | Failed callback |
Code Example
await OpenIM.iMManager.userManager.subscribeUsersStatus([]);
// todo
Function Prototype
- (void)subscribeUsersStatus:(NSArray<NSString *> *)userIDs
onSuccess:(nullable OIMUserStatusInfosCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDs | NSArray<NSString *> | Yes | List of user IDs |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
onSuccess | NSArray<OIMUserStatusInfo > | Successful return |
onFailure | OIMFailureCallback | Failed return |
Code Example
[OIMManager.manager subscribeUsersStatus:@[]
onSuccess:^(NSArray<OIMUserStatusInfo *> * _Nullable statusInfos) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void subscribeUsersOnlineStatus(OnBase<List<UsersOnlineStatus>> callBack, List<String> uid)
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
callback | OnBase<List<UsersOnlineStatus>> | Yes | User ID |
ids | List<String> | Yes | User ID |
Code Example
OpenIMClient.getInstance().userInfoManager.subscribeUsersOnlineStatus(new OnBase<List<UsersOnlineStatus>>() {
@Override
public void onError(int code, String error) {
}
@Override
public void onSuccess(List<UsersOnlineStatus> data) {
// todo
}
},ids);
Function Prototype
IMSDK.subscribeUsersStatus(userIDList: string[], operationID?: string): Promise<WsResponse<UserOnlineState[]>>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDList | string[] | Yes | List of user IDs |
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse<UserOnlineState[]>> | User online status details list |
Promise.catch() | Promise<WsResponse> | Failed callback |
Code Example
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();
const userIDList = ['userID1', 'userID2'];
IMSDK.subscribeUsersStatus(userIDList)
.then(({ data }) => {
// data: User online status details list
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
IMSDK.asyncApi('subscribeUsersStatus', operationID: string, userIDList: string[]): Promise<UserOnlineState[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used to locate problems, keep unique, recommended to use current time and random number |
userIDList | string[] | Yes | List of user IDs |
Return Results
Using the
openim-uniapp-polyfill
package, the function is made Promise-based, and when called, you need to usethen
andcatch
to judge and handle the successful and failed callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<UserOnlineState[]> | User online status details list |
Promise.catch() | Promise<CatchResponse> | Failed callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
const userIDList = ['userID1', 'userID2'];
IMSDK.asyncApi('subscribeUsersStatus', IMSDK.uuid(), userIDList)
.then((data) => {
// data: User online status details list
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
OpenIMSDKRN.subscribeUsersStatus(userIDList: string[], operationID: string): Promise<UserOnlineState[]>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
userIDList | string[] | Yes | User ID list |
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<UserOnlineState[]> | User online status details list |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
const userIDList = ['userID1', 'userID2'];
const data = await OpenIMSDKRN.subscribeUsersStatus(userIDList, 'operationID');
.then((data) => {
// data: User online status details list
})
.catch(({ errCode, errMsg }) => {
// Call failed
});
Function Prototype
public static void SubscribeUsersStatus(OnBase<List<OnlineStatus>> cb, string[] userIds)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase<List<UsersOnlineStatus>> | Yes | Callback |
userIdS | string[] | Yes | Array of UserID |
Code Example
IMSDK.SubscribeUsersStatus((list, errCode, errMsg)=>{
},userIdS);