Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Notifications

Send local notifications using the platform’s notification system. Every snippet below is excerpted from docs/examples/system/snippets.ts — CI links it on every PR.

Sending a notification

notificationSend("Build complete", "All targets compiled in 4.2s.")

Reacting to a tap

notificationOnTap((id: string, action?: string) => {
    console.log(`tapped notification ${id}; action=${action ?? "(default)"}`)
})

action is the action-button identifier when the user picks a button, or undefined for the default banner tap.

Cancelling a scheduled notification

notificationCancel("daily-reminder")

notificationCancel(id) is a no-op if no scheduled notification with that id exists.

Push notifications (APNs / Firebase)

notificationRegisterRemote((token: string) => {
    console.log(`APNs device token: ${token}`)
})

notificationOnReceive((payload: object) => {
    console.log(`got remote payload: ${JSON.stringify(payload)}`)
})

notificationRegisterRemote(cb) fires once when the OS returns a device token — on Apple platforms the token is the canonical uppercase hex string APNs expects. notificationOnReceive(cb) runs whenever a remote payload arrives while the app is foregrounded; the payload is the APNs aps userInfo dictionary (or equivalent platform shape) converted to a plain object.

Requires the relevant platform capability (APNs entitlement on iOS/macOS, Firebase Messaging on Android — wired via JNI through PerryFirebaseMessagingService, see #98). No-op on platforms without a push pipeline (tvOS, visionOS, watchOS, GTK4, Windows, Web).

Platform Implementation

PlatformBackend
macOSUNUserNotificationCenter
iOSUNUserNotificationCenter
AndroidNotificationManager
WindowsToast notifications
LinuxGNotification
WebWeb Notification API

Permissions: On macOS, iOS, and Web, the user may need to grant notification permissions. On first use, the system will prompt automatically.

Next Steps