reportFeedEngagement static method
Future<void>
reportFeedEngagement(
- NotificationFeedItem feedItem,
- String interactionString, {
- required dynamic onSuccess(
- void result
- required dynamic onError(
- 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);
}
}