invite
Introduction
Invite another user with signaling message.
Parameter details
Parameter name |
Parameter type |
Required |
Description |
invitee |
string |
yes |
The ID of the target user to invite. |
data |
string |
yes |
The custom data carried by the invitation. |
timeout |
number |
no |
The timeout configuration of the invitation. 30 seconds as default, while 0 represent will not timeout. |
onlineUserOnly |
boolean |
no |
Whether the message can be received by online users only. |
offlinePushInfo |
V2TimOfflinePushInfo |
no |
Offline push information. The title, body and external content carried and shown when a message is pushed offline. |
Returned template
V2TimValueCallback<string>
{
code : number
desc : string
data : string
}
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 |
string |
The ID of the invitation created. |
Code example
import { TencentImSDKPlugin } from 'react-native-tim-js';
const listener = {
onInvitationCancelled: (inviteID, inviter, data) => {
},
onInvitationTimeout: (inviteID, inviteeList) => {
},
onInviteeAccepted: (inviteID, invitee, data) => {
},
onInviteeRejected: (inviteID, invitee, data) => {
},
onReceiveNewInvitation: (inviteID, inviter, groupID, inviteeList, data) => {
},
};
TencentImSDKPlugin.v2TIMManager
.getSignalingManager()
.addSignalingListener(listener);
const inviteRes = await TencentImSDKPlugin.v2TIMManager
.getSignalingManager()
.invite(
'',
'data',
30,
false,
{}
);
if (inviteRes.code === 0) {
inviteRes.data;
}