Extensions on
V2TIMManager
Methods
addSignalingListener(listener:)
public func addSignalingListener(listener: V2TIMSignalingListener)
1.1 Add the signaling listener
removeSignalingListener(listener:)
public func removeSignalingListener(listener: V2TIMSignalingListener)
1.2 Remove the signaling listener
invite(invitee:data:onlineUserOnly:offlinePushInfo:timeout:succ:fail:)
public func invite(invitee: String, data: String?, onlineUserOnly: Bool, offlinePushInfo: V2TIMOfflinePushInfo?, timeout: Int, succ: V2TIMSucc?, fail: V2TIMFail?) -> String?
1.3 Invite someone
Parameters
Name | Type | Description |
---|---|---|
invitee | String |
Invitee's user ID |
data | String? |
Custom data |
timeout | Int |
Timeout duration, in seconds. If it is set to 0, the SDK will not perform timeout detection or trigger the onInvitationTimeout callback. |
onlineUserOnly | Bool |
Whether the message can be received only by online users. If this field is set to true, the message can be received only by online users, and the invitation and the canceling, accepting, rejecting, and timeout of the invitation will not appear among historical messages. |
offlinePushInfo | V2TIMOfflinePushInfo? |
Offline push information, where the desc field is required. The information specified by desc will be displayed by default during push. |
Returns
inviteID Invitation ID. If the invitation fails, null is returned.
inviteInGroup(groupID:inviteeList:data:onlineUserOnly:timeout:succ:fail:)
public func inviteInGroup(groupID: String, inviteeList: Array<String>, data: String?, onlineUserOnly: Bool, timeout: Int, succ: V2TIMSucc?, fail: V2TIMFail?) -> String?
1.4 Invite certain users in the group
Parameters
Name | Type | Description |
---|---|---|
groupID | String |
ID of the inviter's group |
inviteeList | Array<String> |
List of invitees. Invitees specified by inviteeList must be in the group specified by groupID. Otherwise, the invitation fails. |
timeout | Int |
Timeout duration, in seconds. If it is set to 0, the SDK will not perform timeout detection or trigger the onInvitationTimeout callback. |
onlineUserOnly | Bool |
Whether the message can be received only by online users. If this field is set to true, the message can be received only by online users, and the invitation and the canceling, accepting, rejecting, and timeout of the invitation will not appear among historical messages. |
Returns
inviteID Invitation ID. If the invitation fails, null is returned.
cancel(inviteID:data:succ:fail:)
public func cancel(inviteID: String, data: String?, succ: V2TIMSucc?, fail: V2TIMFail?)
1.5 Cancel an invitation (called by the inviter)
Parameters
Name | Type | Description |
---|---|---|
inviteID | String |
Invitation ID |
accept(inviteID:data:succ:fail:)
public func accept(inviteID: String, data: String?, succ: V2TIMSucc?, fail: V2TIMFail?)
1.6 The invitee accepts the invitation
reject(inviteID:data:succ:fail:)
public func reject(inviteID: String, data: String?, succ: V2TIMSucc?, fail: V2TIMFail?)
1.7 The invitee rejects the invitation
getSignallingInfo(msg:)
public func getSignallingInfo(msg: V2TIMMessage) -> V2TIMSignalingInfo?
1.8 Get the signaling information
If onlineUserOnly is set to false in the invite operation, a custom message is generated for each signaling operation (including the invite, cancel, accept, reject, and timeout operations). The message will be delivered to users via V2TIMAdvancedMsgListener -> onRecvNewMessage and can be pulled by users via historical message pulling. If you want to customize the display text based on the signaling information, call this API to get the signaling information.
Parameters
Name | Type | Description |
---|---|---|
msg | V2TIMMessage |
Message object |
Returns
V2TIMSignalingInfo Signaling information. If the value is nil, msg is not a signaling message.
addInvitedSignaling(signalingInfo:succ:fail:)
public func addInvitedSignaling(signalingInfo: V2TIMSignalingInfo, succ: V2TIMSucc?, fail: V2TIMFail?)
1.9 Add invitation signaling (can be used for invitation signaling triggered by group offline push messages)
This API is mainly used to sync group invitations sent to offline users after they are online. When the invitee clicks the offline push message notification and starts the App:
- If the inviter sends 1v1 signaling while the invitee is offline, the SDK can automatically sync the invitation signaling. If the invitation has not timed out, onReceiveNewInvitation will be triggered.
- If the inviter sends group signaling while the invitee is offline, different SDK behaviors are as follows:
- versions lower than 6.7: SDK cannot automatically sync the invitation signaling. For the invitees to handle the invitation after they are online, the inviter can send an extra C2C offline push message carrying the V2TIMSignalingInfo object to each invitee and, when the invitees receive the offline push message, call addInvitedSignaling to sync V2TIMSignalingInfo to SDK.
- versions equal or higher than 6.7: SDK can automatically sync messages in the last 30 seconds. If there are invitation signaling messages that have not timed out, onReceiveNewInvitation will be triggered. You don't need to call this API to sync the invitation signaling info.
modifyInvitation(inviteID:data:succ:fail:)
public func modifyInvitation(inviteID: String, data: String, succ: V2TIMSucc?, fail: V2TIMFail?)
1.10 Modify the invitation (supported only in 6.7 and later versions)