deleteFriend
Feature Description
Note
Delete a friend.
Warning
(1) Due to the mutual nature of friendships, this function only removes the other party from one's own friend list; (2) Deleting a friend does not automatically delete the conversation. To delete the conversation, you can call the function to delete the conversation.
Relevant callback: onFriendDeleted
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<dynamic> deleteFriend({
required String userID,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
userID | String | Yes | User ID |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
~ | ~ | Success if no exception |
Code Example
await OpenIM.iMManager.friendshipManager.deleteFriend(userID: 'userID');
// todo
Function Prototype
- (void)deleteFriend:(NSString *)friendUserID
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
friendUserID | NSString | Yes | User ID |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
onSuccess | OIMSuccessCallback | Success |
onFailure | OIMFailureCallback | Failure |
Code Example
[OIMManager.manager deleteFriend:@""
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void deleteFriend(OnBase<String> callBack, String uid)
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase | Yes | Callback |
uid | String | Yes | User ID |
Return Results
Code Example
OpenIMClient.getInstance().friendshipManager.deleteFriend(new OnBase<String>(){...},uid)
Function Prototype
IMSDK.deleteFriend(userID: string, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
userID | string | Yes | User ID |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Success |
Promise.catch() | Promise<WsResponse> | Failure |
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();
IMSDK.deleteFriend('userID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('deleteFriend', operationID: string, userID: string): Promise<void>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for troubleshooting, recommended to use current time and a random number |
userID | string | Yes | User ID |
Return Results
The
openim-uniapp-polyfill
package makes the function Promise-based. When calling, you need to usethen
andcatch
to determine and handle the success and failure callbacks.
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<void> | Successful call |
Promise.catch() | Promise<CatchResponse> | Failed call |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('deleteFriend', IMSDK.uuid(), 'userID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.deleteFriend(userID: string, operationID: string): Promise<void>;
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for troubleshooting, recommended to use current time and a random number |
userID | string | Yes | User ID |
Return Result
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.deleteFriend('userID', 'operationID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});