addParticipants method
Add new participants to the conversation.
It's possible only on the following conditions:
- the participants are users of the main Voximplant developer account or its child accounts
- the current user can manage other participants (ConversationParticipant.canManageParticipants() is true)
- the conversation is not a direct one (VIConversation.direct is false) Duplicated users are ignored. Will cause VIException if at least one user does not exist or already belongs to the conversation.
Other parties of the conversation (online participants and logged in clients) can be informed about adding participants via the VIMessenger.onEditConversation callback.
participants
- List of VIConversationParticipant to be added to the conversation. Shouldn't contain null(s), be null or empty list.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Implementation
Future<VIConversationEvent> addParticipants(
List<VIConversationParticipant> participants,
) async {
try {
Map<String, dynamic>? data =
await _methodChannel.invokeMapMethod('Messaging.addParticipants', {
'conversation': uuid,
'participants': participants.map((e) => e._toMap).toList(),
});
if (data == null) {
_VILog._e('VIConversation: addParticipants: data was null, skipping');
throw VIException(
VIMessagingError.ERROR_INTERNAL,
'VIConversation:addParticipants: data was null',
);
}
return VIConversationEvent._fromMap(data);
} on PlatformException catch (e) {
throw VIException(e.code, e.message);
}
}