Skip to content

Commit c1293e4

Browse files
authored
Merge pull request #325 from cornerman/serviceworker-registration-notification
Add showNotification/getNotifications to ServiceWorkerRegistration
2 parents 544e544 + 3f1bbd6 commit c1293e4

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/main/scala/org/scalajs/dom/experimental/serviceworkers/ServiceWorkers.scala

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import scala.scalajs.js
44
import scala.scalajs.js.annotation._
55
import scala.scalajs.js.|
66

7-
import org.scalajs.dom.experimental.{Request, RequestInfo, Response, Sequence}
7+
import org.scalajs.dom.experimental.{
8+
Notification, NotificationOptions, Request, RequestInfo, Response, Sequence
9+
}
810
import org.scalajs.dom.raw.{WorkerGlobalScope, ErrorEvent}
911
import org.scalajs.dom.webgl.RenderingContext
1012
import org.scalajs.dom.{Event, EventTarget, MessagePort}
@@ -246,6 +248,45 @@ trait ServiceWorkerRegistration extends EventTarget {
246248
* MDN
247249
*/
248250
var onupdatefound: js.Function1[Event, _] = js.native
251+
252+
/**
253+
* The getNotifications() method of the ServiceWorkerRegistration interface
254+
* returns a list of the notifications in the order that they were created
255+
* from the current origin via the current service worker registration.
256+
* Origins can have many active but differently-scoped service worker
257+
* registrations. Notifications created by one service worker on the same
258+
* origin will not be available to other active services workers on that same
259+
* origin.
260+
*
261+
* MDN
262+
*/
263+
def getNotifications(
264+
options: GetNotificationOptions = ???): js.Promise[Sequence[Notification]] = js.native
265+
266+
/**
267+
* The showNotification() method of the ServiceWorkerRegistration interface
268+
* creates a notification on an active service worker.
269+
*
270+
* MDN
271+
*/
272+
def showNotification(title: String,
273+
options: NotificationOptions = ???): js.Promise[Unit] = js.native
274+
}
275+
276+
/**
277+
* An object containing options to filter the notifications returned.
278+
*
279+
* MDN
280+
*/
281+
trait GetNotificationOptions extends js.Object {
282+
283+
/**
284+
* A DOMString representing a notification tag. If specified, only
285+
* notifications that have this tag will be returned.
286+
*
287+
* MDN
288+
*/
289+
var tag: js.UndefOr[String] = js.undefined
249290
}
250291

251292
/**

0 commit comments

Comments
 (0)