notifications.idl (3070B)
1 // GENERATED CONTENT - DO NOT EDIT 2 // Content was automatically extracted by Reffy into webref 3 // (https://github.com/w3c/webref) 4 // Source: Notifications API Standard (https://notifications.spec.whatwg.org/) 5 6 [Exposed=(Window,Worker)] 7 interface Notification : EventTarget { 8 constructor(DOMString title, optional NotificationOptions options = {}); 9 10 static readonly attribute NotificationPermission permission; 11 [Exposed=Window] static Promise<NotificationPermission> requestPermission(optional NotificationPermissionCallback deprecatedCallback); 12 13 static readonly attribute unsigned long maxActions; 14 15 attribute EventHandler onclick; 16 attribute EventHandler onshow; 17 attribute EventHandler onerror; 18 attribute EventHandler onclose; 19 20 readonly attribute DOMString title; 21 readonly attribute NotificationDirection dir; 22 readonly attribute DOMString lang; 23 readonly attribute DOMString body; 24 readonly attribute USVString navigate; 25 readonly attribute DOMString tag; 26 readonly attribute USVString image; 27 readonly attribute USVString icon; 28 readonly attribute USVString badge; 29 [SameObject] readonly attribute FrozenArray<unsigned long> vibrate; 30 readonly attribute EpochTimeStamp timestamp; 31 readonly attribute boolean renotify; 32 readonly attribute boolean? silent; 33 readonly attribute boolean requireInteraction; 34 [SameObject] readonly attribute any data; 35 [SameObject] readonly attribute FrozenArray<NotificationAction> actions; 36 37 undefined close(); 38 }; 39 40 dictionary NotificationOptions { 41 NotificationDirection dir = "auto"; 42 DOMString lang = ""; 43 DOMString body = ""; 44 USVString navigate; 45 DOMString tag = ""; 46 USVString image; 47 USVString icon; 48 USVString badge; 49 VibratePattern vibrate; 50 EpochTimeStamp timestamp; 51 boolean renotify = false; 52 boolean? silent = null; 53 boolean requireInteraction = false; 54 any data = null; 55 sequence<NotificationAction> actions = []; 56 }; 57 58 enum NotificationPermission { 59 "default", 60 "denied", 61 "granted" 62 }; 63 64 enum NotificationDirection { 65 "auto", 66 "ltr", 67 "rtl" 68 }; 69 70 dictionary NotificationAction { 71 required DOMString action; 72 required DOMString title; 73 USVString navigate; 74 USVString icon; 75 }; 76 77 callback NotificationPermissionCallback = undefined (NotificationPermission permission); 78 79 dictionary GetNotificationOptions { 80 DOMString tag = ""; 81 }; 82 83 partial interface ServiceWorkerRegistration { 84 Promise<undefined> showNotification(DOMString title, optional NotificationOptions options = {}); 85 Promise<sequence<Notification>> getNotifications(optional GetNotificationOptions filter = {}); 86 }; 87 88 [Exposed=ServiceWorker] 89 interface NotificationEvent : ExtendableEvent { 90 constructor(DOMString type, NotificationEventInit eventInitDict); 91 92 readonly attribute Notification notification; 93 readonly attribute DOMString action; 94 }; 95 96 dictionary NotificationEventInit : ExtendableEventInit { 97 required Notification notification; 98 DOMString action = ""; 99 }; 100 101 partial interface ServiceWorkerGlobalScope { 102 attribute EventHandler onnotificationclick; 103 attribute EventHandler onnotificationclose; 104 };