ReviewOS

also looking at this

craft-native/craft

feat(notifications): make the banner answerable — clicks, buttons, and a crash

#74
Merged glennmichael123 wants to merge feat/notification-actions into main
8 files +942 -17
packages/typescript/src/types.tsmodified+39-8
Changes to packages/typescript/src/types.ts
@@ -814,12 +814,51 @@ export interface AppInfo {
814814/**
815815 * Notification options
816816 */
817/**
818 * A button on a notification banner.
819 *
820 * macOS shows two directly on a banner and puts any others behind an
821 * "Options" disclosure, so craft accepts at most four — past that they are
822 * a menu the user has to go looking for rather than a choice they can see.
823 *
824 * Two spellings are accepted. `{ id, label }` is the one to use. `{ action,
825 * title }` is what this type has said since before anything implemented it,
826 * and it keeps working rather than being deleted out from under whoever wrote
827 * against it — the field was published, it just never did anything.
828 */
829export type NotificationAction =
830 | {
831 /** Comes back as `actionId` in `craft.notifications.onAction`. */
832 id: string
833 /** The text on the button. */
834 label: string
835 }
836 | {
837 /** @deprecated Use `id`. */
838 action: string
839 /** @deprecated Use `label`. */
840 title: string
841 }
842
817843export interface NotificationOptions {
818844 /**
819845 * Notification title (required)
820846 */
821847 title: string
822848
849 /**
850 * Buttons on the banner.
851 *
852 * Pressing one brings the app forward and fires
853 * `craft.notifications.onAction` with `{ notificationId, actionId }` —
854 * which is what lets a prompt be answered without switching to the app
855 * first.
856 *
857 * Two buttons cannot share an `id`: the response names the button by id,
858 * and for an Approve/Deny prompt that name is the entire answer.
859 */
860 actions?: NotificationAction[]
861
823862 /**
824863 * Notification body text
825864 */
@@ -839,14 +878,6 @@ export interface NotificationOptions {
839878 */
840879 sound?: string
841880
842 /**
843 * Action buttons (platform dependent)
844 */
845 actions?: Array<{
846 action: string
847 title: string
848 }>
849
850881 /**
851882 * Notification tag (for grouping/replacing)
852883 */