Mark Notification Tray Item Seen

Fine-grained Tracking

Update seen status for individual notification items

User Interaction

Track when users click or interact with specific notifications

Overview

The notification tray item markSeen() method updates the seen status of a specific notification tray item, enabling fine-grained read tracking. Use this when a user clicks or interacts with an individual notification. Each tray item has its own lastSeenAt timestamp, which is recorded on the server when this method is called.

Implementation Guide

import AmitySDK

class NotificationItemCell: UITableViewCell {
    var notificationItem: AmityNotificationTrayItem?
    
    @IBAction func handleItemTap(_ sender: UITapGestureRecognizer) {
        guard let item = notificationItem else { return }
        
        // Mark individual item as seen
        item.markSeen { [weak self] result in
            DispatchQueue.main.async {
                switch result {
                case .success:
                    self?.updateSeenUI()
                case .failure(let error):
                    self?.handleError(error)
                }
            }
        }
        
        // Navigate to relevant content
        navigateToContent(item)
    }
    
    private func updateSeenUI() {
        // Update visual indicators
        seenIndicator.isHidden = true
        backgroundColor = UIColor.systemBackground
    }
}

Usage Patterns

Error Handling

Best Practices