Skip to main content

Events reference

Subscribe with notifications.on(event, cb) or kit.on(event, cb); both return an unsubscribe function. See the Events guide for the envelope shape and how push/local are distinguished.

Event map

EventPayload fields (on the event + under event.data)
readyplatform, capabilities
notificationReceivedpayload, type ('push' | 'local'), platform
notificationActionPerformedaction, notification, inputValue, platform
notificationSentpayload, type
notificationScheduledoptions, type
notificationCancelledid, type
notificationShownoptions, type ('inApp'), id
channelCreatedchannel
channelDeletedchannelId
tokenReceivedtoken
tokenRefreshedtoken
permissionChangedgranted, status
subscribedtopic
unsubscribedtopic
errorerror, context

Event object

Every listener receives:

interface NotificationEvent {
id: string; // unique per emission (crypto.randomUUID when available)
type: string; // the event name — canonical, never clobbered
timestamp: Date;
data?: any; // the original payload
// payload fields are also spread on the top level
}

Typed subscriptions

on is generic over NotificationEventMap, so the callback payload is typed per event:

notifications.on('tokenRefreshed', (event) => {
event.token; // string
});

notifications.on('permissionChanged', (event) => {
event.granted; // boolean
event.status; // PermissionStatus
});

NotificationReceivedEvent, NotificationActionPerformedEvent, NotificationSentEvent, NotificationScheduledEvent, NotificationCancelledEvent, NotificationChannelCreatedEvent, NotificationChannelDeletedEvent, TokenReceivedEvent, TokenRefreshedEvent, PermissionChangedEvent, SubscribedEvent, UnsubscribedEvent, ReadyEvent, ErrorEvent — all exported from notification-kit.