Skip to content

Improve scope documentation for amp-install-serviceworker and amp-web-push scopes #26260

Open
@westonruter

Description

What's the issue?

Normally when wanting to install a service worker, the way to do so is to use the aptly-named amp-install-serviceworker component.

However, if wanting to then add push notifications, the amp-web-push component needs to be used.

This introduces a problem because the amp-web-push component also takes the responsibility of installing a service worker (apparently). Because only one service worker can be active on a given page, this introduces a conflict.

This being said, in testing if I add both components to the page, it doesn't seem to result in the service worker attempting to be installed twice. In fact, only the service worker referenced in amp-install-serviceworker is being added, even when I put <amp-web-push> before <amp-install-serviceworker>. I'm not seeing <amp-web-push> install any service worker at all, so maybe I am not correctly understanding how it is supposed to work. However, if it is supposed to install a service worker it could create major confusions when a user tries to supply a service worker script that is specific to push notifications on <amp-web-push> but another script entirely for <amp-install-serviceworker>. This should get raised by the component as a user error.

Also, ideally the amp-web-push component would allow omission of the service-worker-url attribute if there is an <amp-install-serviceworker> element on the page. This would also allow amp-web-push to take advantage of the capabilities of amp-install-serviceworker, such as installing the origin service worker while accessing a page loaded from an AMP Cache.

All of this to say, I am not clear if there is actually a conflict. But since the documentation for the components does not refer to each other, it is not clear if they can work together. If not, they should. And the docs should be updated to clarify.

How do we reproduce the issue?

Include both amp-service-worker and amp-web-push on a page.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions