setFriendListener
Feature Introduction
Description
Set the relationship chain event listener. For related events of relationship changes, asynchronous callback notifications are provided, so the UI can perceive and process them in a timely manner.
Note
(1) Call immediately after initSDK; (2) Can only be called once.
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future setFriendshipListener(OnFriendshipListener listener)
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
listener | OnFriendshipListener | Yes |
Return Results
~
Code Example
OpenIM.iMManager.friendshipManager.setFriendshipListener(OnFriendshipListener(
onBlacklistAdded: (BlacklistInfo i){},
onBlacklistDeleted: (BlacklistInfo i){},
onFriendAdded: (FriendInfo i){},
onFriendApplicationAccepted: (FriendApplicationInfo i){},
onFriendApplicationAdded: (FriendApplicationInfo i){},
onFriendApplicationDeleted: (FriendApplicationInfo i){},
onFriendApplicationRejected: (FriendApplicationInfo i){},
onFriendDeleted: (FriendInfo i){},
onFriendInfoChanged: (FriendInfo i){},
));
Function Prototype
- (void)addFriendListener:(id<OIMFriendshipListener>)listener NS_SWIFT_NAME(addFriendListener(listener:));
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
listener | id < OIMFriendshipListener > | Yes |
Return Results
None
Code Example
[OIMManager.callbacker addFriendListener:self];
Function Prototype
public void setOnFriendshipListener(OnFriendshipListener listener)
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
listener | id <OnFriendshipListener> | Yes |
Return Results
None
Code Example
OpenIMClient.getInstance().friendshipManager.setOnFriendshipListener(new OnFriendshipListener{...} )
Note
Automatically set after successful login. Listeners can be directly used on the client. For details on friendship events, see
Note
Automatically set after initialization. Callbacks are passed to the client via globalEvent
. For details on friendship events, see
Attention
After successful initialization, it's set automatically. You can directly use the listener on the client side. Details on friendship events can be found here
Function Prototype
public static void SetFriendShipListener(IFriendShipListener listener)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
listener | IFriendShipListener | Yes |
Return Result
Code Example
IMSDK.SetFriendShipListener(listener)