Skip to content

Add notificationCloses to SwPush #52244

@nsbarsukov

Description

@nsbarsukov

Which @angular/* package(s) are relevant/related to the feature request?

service-worker

Description

Angular official documentation page says:

When using the Angular service worker, push notification interactions are handled using the SwPush service. To learn more about the browser APIs involved see Push API and Using the Notifications API.

The SwPush service contains notificationClicks property to handle serviceWorkerGlobalScope.notificationclick.

But serviceWorkerGlobalScope also emits notificationclose event.

Proposed solution

Add notificationCloses property to SwPush service.

Proposed steps:

  • Add this.scope.addEventListener('notificationclose', (event) => this.onClose(event!)); (similar to already existed notificationclick event)
    this.scope.addEventListener('notificationclick', (event) => this.onClick(event!));
  • Add this.notificationCloses = this.sw.eventsOfType('NOTIFICATION_CLOSE') (similar to already existed NOTIFICATION_CLICK)
    this.notificationClicks =
    this.sw.eventsOfType('NOTIFICATION_CLICK').pipe(map((message: any) => message.data));

Alternatives considered

-

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: service-workerIssues related to the @angular/service-worker package

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions