setUserListener
Feature Introduction
Description
Set user event listener. It provides asynchronous callback notifications for changes in the login user's profile and changes in the online status of subscribed users. This ensures the UI is updated promptly.
Note
(1) Call immediately after initSDK; (2) Can only be called once.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Uinty
Function Prototype
Future setUserListener(OnUserListener listener)
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
listener | OnUserListener | Callback function for user info updates |
Code Example
OpenIM.iMManager.userManager.setUserListener(OnUserListener(
onSelfInfoUpdated: (UserInfo userInfo){},
userStatusChanged: (UserStatusInfo statusInfo){}
));
Function Prototype
- (void)setUserListenerWithUserInfoUpdate:(nullable OIMUserInfoCallback)onUserInfoUpdate
onUserStatusChanged:(nullable OIMUserStatusInfoCallback)onUserStatusChanged;
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
onUserInfoUpdate | OIMUserInfo | Callback function for user info updates |
onUserStatusChanged | OIMUserStatusInfo | Callback function for user status updates |
Code Example
[OIMManager.callbacker setSelfUserInfoUpdateListenerWithUserInfoUpdate:^(OIMUserInfo * _Nullable userInfo) {
} onUserStatusChanged:^(OIMUserStatusInfo * _Nullable statusInfo) {
}];
Function Prototype
public void setOnUserListener(OnUserListener listener)
Input Parameter
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
listener | OnUserListener | Callback function for user info updates |
Return Result
Code Example
OpenIMClient.getInstance().userInfoManager.setOnUserListener(new OnUserListener(){...})
Note
It's automatically set after a successful login. You can directly use the listener on the client side. For details on user events, see here.
Note
It's automatically set after successful initialization. Callbacks are transmitted to the client through globalEvent
. For details on user events, see here.
Attention
After successful initialization, it's set automatically. You can directly use the listener on the client side. Details on user events can be found here
Function Prototype
public static void SetUserListener(IUserListener listener)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
listener | IUserListener | Yes | Callback function for user status updates |
Return Result
Code Example
IMSDK.SetUserListener(listener);