Notification Tray

Real-time Notifications

Keep users engaged with instant notifications for posts, reactions, comments, and replies

Flexible Integration

Easy-to-use SDK methods for seamless notification tray integration

Granular Control

Fine-grained read tracking with both global and per-item seen states

Cross-platform Support

Consistent notification experience across iOS, Android, and Web platforms

Architecture Overview

Key Features

The Notification Tray SDK Feature enhances user engagement and connectivity within your application by providing comprehensive notification management capabilities.

Data Models

Notification Tray Item

PropertyTypeDescription
notificationIdStringUnique identifier of notification item
lastSeenAtDatetimeTimestamp when the notification was last seen
lastOccuredAtDatetimeTimestamp when the notification last occurred
actorsList<AmityNotificationActors>Data of users that acted on this notification item
actorCountIntNumber of users that acted on this notification item
actionTypeStringType of action that triggered this notification
trayItemCategoryStringCategory for when action is either “mention” or “reply”
targetIdStringObject ID of the target
targetTypeStringType of target for this action
referenceIdStringOptional ObjectId of the reference
referenceTypeStringType of reference for this action
parentIdStringOptional ObjectId of parent
textStringReady to render text without any templating
templatedTextStringReady to render text with templating for client interpretation
isSeenBooleanWhether this notification item has been seen
isRecentBooleanWhether this notification item is recent or older
usersList<AmityUser>List of users that acted on this notification

Notification Tray Seen State

PropertyTypeDescription
lastTraySeenAtDatetimeTimestamp when the tray was last seen
lastTrayOccuredAtDatetimeTimestamp when the last tray item occurred
isSeenBooleanWhether the entire tray has been seen

Implementation Strategies

Quick Start Guide

1

Initialize Repository

Set up the notification repository in your application
import AmitySDK

class NotificationViewController: UIViewController {
    private let notificationRepository = AmityNotificationTrayRepository()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        setupNotificationHandling()
    }
}
2

Check Notification State

Implement badge indicators based on tray seen status
func checkForUnseenNotifications() {
    notificationRepository.getNotificationTraySeen { [weak self] result in
        DispatchQueue.main.async {
            switch result {
            case .success(let trayData):
                self?.updateNotificationBadge(!trayData.isSeen)
            case .failure(let error):
                print("Error checking notifications: \(error)")
            }
        }
    }
}
3

Mark as Seen

Update seen status when user interacts with notifications
func markTrayAsSeen() {
    notificationRepository.markNotificationTraySeen { [weak self] result in
        switch result {
        case .success:
            self?.checkForUnseenNotifications() // Refresh state
        case .failure(let error):
            print("Error marking tray as seen: \(error)")
        }
    }
}