acceptFriendApplication

Introduction

Accept friend or contact application.

Parameter details

Parameter name Parameter type Required Description
responseType FriendResponseTypeEnum yes The relationship type between the friend(contact) and the current user, including one-way friend and two-way friend.
type FriendApplicationTypeEnum yes The relationship application type, reflects who made this application.
userID string yes The target user ID.

Returned template

V2TimValueCallback<V2TimFriendOperationResult>

{
    code : number
    desc : string
    data : {
        resultCode : int//Operation result error code
        resultInfo : String//Operation result description
        userID : String//Agree with your friend's ID
    }
}

Return value details

name type description
code number Request result: Error codes. 0 means success.
desc string The description of the error. It will be empty if success.
data V2TimFriendOperationResult The result of the operation.

Code example

import {
    TencentImSDKPlugin,
    FriendResponseTypeEnum,
    FriendApplicationTypeEnum,
} from 'react-native-tim-js';


const getFriendApplicationListRes = await TencentImSDKPlugin.v2TIMManager
    .getFriendshipManager()
    .getFriendApplicationList();
if (getFriendApplicationListRes.code === 0) {

    getFriendApplicationListRes.data?.unReadCount;
    getFriendApplicationListRes.data?.friendApplicationList?.forEach(
        (element) => {

            const acceptFriendApplicationRes =
                await TencentImSDKPlugin.v2TIMManager
                    .getFriendshipManager()
                    .acceptFriendApplication(
                        FriendResponseTypeEnum.V2TIM_FRIEND_ACCEPT_AGREE,
                        element.type as FriendApplicationTypeEnum,
                        ''
                    );
            if (acceptFriendApplicationRes.code === 0) {

                acceptFriendApplicationRes.data?.resultCode;
                acceptFriendApplicationRes.data?.resultInfo;
                acceptFriendApplicationRes.data?.userID;
            }
        }
    );
}

results matching ""

    No results matching ""