reportFeedEngagement static method

Future<void> reportFeedEngagement(
  1. NotificationFeedItem feedItem,
  2. String interactionString, {
  3. required dynamic onSuccess(
    1. void result
    )?,
  4. required dynamic onError(
    1. CometChatException excep
    )?,
})

Reports engagement for a NotificationFeedItem with a given interaction string.

Android Reference: CometChat.reportFeedEngagement(NotificationFeedItem, String)

The interactionString describes the type of engagement (e.g., "viewed", "clicked", "dismissed"). This is sent as the topic field in the request body.

@param feedItem The NotificationFeedItem to report engagement for. @param interactionString The interaction type (e.g., "viewed", "clicked"). @param onSuccess Callback invoked on successful engagement reporting. @param onError Callback invoked if an error occurs.

Implementation

static Future<void> reportFeedEngagement(
    NotificationFeedItem feedItem, String interactionString,
    {required Function(void result)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    final sdk = SdkRegistry.getInstance();
    await sdk.notificationFeed.reportEngagement(feedItem.id, interactionString);
    if (onSuccess != null) onSuccess(null);
  } on SdkException catch (sdkEx) {
    final cometChatEx = CometChatException(
      sdkEx.code,
      sdkEx.details ?? sdkEx.message,
      sdkEx.message,
    );
    _errorCallbackHandler(cometChatEx, null, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
}