tagConversation static method

Future<Conversation?> tagConversation(
  1. String conversationWith,
  2. String conversationType,
  3. List<String> tags, {
  4. required dynamic onSuccess(
    1. Conversation conversation
    )?,
  5. required dynamic onError(
    1. CometChatException excep
    )?,
})

Tag a conversation

conversationWith The id of conversation

conversationType The user or group

Tag a conversation with custom tags.

Migration Note: Migrated from platform channels to native Dart implementation. Uses ConversationRepository for tagging conversations. Behavior and signature remain identical for backward compatibility.

Android Reference: CometChat.tagConversation(String conversationWith, String conversationType, List<String> tags, CallbackListener<Conversation>)

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<Conversation?> tagConversation(
    String conversationWith, String conversationType, List<String> tags,
    {required Function(Conversation conversation)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    // Get SDK instance
    final sdk = SdkRegistry.getInstance();

    // Call native Dart conversation repository
    final conversation = await sdk.conversations.tagConversation(
      conversationWith,
      conversationType,
      tags,
    );

    // Call success callback
    if (onSuccess != null) onSuccess(conversation);
    return conversation;
  } on SdkException catch (sdkEx) {
    // Convert SdkException to CometChatException
    final cometChatEx = CometChatException(
      sdkEx.code,
      sdkEx.details ?? sdkEx.message,
      sdkEx.message,
    );
    _errorCallbackHandler(cometChatEx, null, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
  return null;
}