getNotificationFeedItem static method

Future<NotificationFeedItem?> getNotificationFeedItem(
  1. String id, {
  2. required dynamic onSuccess(
    1. NotificationFeedItem feedItem
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Fetches a single NotificationFeedItem by its ID.

Android Reference: CometChat.getNotificationFeedItem(String)

Used for deep linking — fetching a specific feed item by its ID.

@param id The announcement/feed item ID. @param onSuccess Callback invoked with the NotificationFeedItem on success. @param onError Callback invoked if an error occurs (e.g., 404 if not found).

Implementation

static Future<NotificationFeedItem?> getNotificationFeedItem(String id,
    {required Function(NotificationFeedItem feedItem)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    final sdk = SdkRegistry.getInstance();
    final feedItem = await sdk.notificationFeed.getItem(id);
    if (onSuccess != null) onSuccess(feedItem);
    return feedItem;
  } 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);
  }
  return null;
}