acceptFriendApplication
Feature Introduction
Description
Accepts a friend request from another user. If successful, a two-way friendship is established immediately.
Note
Related Callbacks: onFriendApplicationAccepted onFriendAdded
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
Future<dynamic> acceptFriendApplication({
required String userID,
String? handleMsg,
String? operationID,
})
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
userID | String | Yes | User ID of the requester |
handleMsg | String | No | Message |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
~ | ~ | Successful if no exception is thrown |
Code Sample
await OpenIM.iMManager.friendshipManager.acceptFriendApplication(
userID: 'userID',
handleMsg: 'ok, i agree',
);
// todo
Function Prototype
- (void)acceptFriendApplication:(NSString *)userID
handleMsg:(NSString *)msg
onSuccess:(nullable OIMSuccessCallback)onSuccess
onFailure:(nullable OIMFailureCallback)onFailure;
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
userID | NSString | Yes | User ID of the requester |
msg | NSString | Yes | Message |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
onSuccess | OIMSuccessCallback | Success return |
onFailure | OIMFailureCallback | Failure return |
Code Sample
[OIMManager.manager acceptFriendApplication:@""
handleMsg:@""
onSuccess:^(NSString * _Nullable data) {
} onFailure:^(NSInteger code, NSString * _Nullable msg) {
}];
Function Prototype
public void acceptFriendApplication(OnBase<String> callBack, String uid, String msg)
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
callBack | OnBase | Yes | Callback interface |
uid | String | Yes | User ID |
msg | String | Yes | Message |
Return Results
Code Sample
OpenIMClient.getInstance().friendshipManager.acceptFriendApplication(new OnBase<String>(){...},uid,msg)
Function Prototype
IMSDK.acceptFriendApplication({
toUserID: string;
handleMsg: string;
}, operationID?: string): Promise<WsResponse>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
toUserID | string | Yes | User ID of the requester |
handleMsg | string | Yes | Operation message |
Return Results
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Success callback |
Promise.catch() | Promise<WsResponse> | Failure 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.acceptFriendApplication({
toUserID: '',
handleMsg: '',
})
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('acceptFriendApplication', operationID: string, {
toUserID: string;
handleMsg: string;
}): Promise<void>
Input Parameters
Parameter Name | Data Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID used to locate issues, must be unique, suggest using current time with a random number |
toUserID | string | Yes | User ID of the requester |
handleMsg | string | Yes | Operation message |
Return Results
Through the
openim-uniapp-polyfill
package, the function is Promise-based. When calling, usethen
andcatch
to determine and handle success and failure callbacks.
Parameter Name | Data Type | Description |
---|---|---|
Promise.then() | Promise<void> | Success callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Sample
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('acceptFriendApplication', IMSDK.uuid(), {
toUserID: '',
handleMsg: '',
})
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.acceptFriendApplication({
toUserID: string;
handleMsg: string;
}, operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
toUserID | string | Yes | User ID of the requester |
handleMsg | string | Yes | Operation message |
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<void> | Callback on successful call |
Promise.catch() | Promise<CatchResponse> | Callback on failed call |
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.acceptFriendApplication({
toUserID: '',
handleMsg: '',
}, 'operationID');
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void AcceptFriendApplication(OnBase<bool> cb, ProcessFriendApplicationParams userIdHandleMsg)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnBase | Yes | Callback |
userIdHandleMsg | ProcessFriendApplicationParams | Yes | Friend Application Params |
Return Result
Code Example
IMSDK.AcceptFriendApplication((suc,errCode,errMsg)=>{
},new ProcessFriendApplicationParams(){
ToUserID = "userid",
HandleMsg = "",
});