ampproject / ampproject/amphtml

amp-web-push: unnecessary pop-up window for push notification permission request for AMP pages on origin/SxG

Open
#27,303 2 comments 2 reactions 0 assignees View on GitHub
P2: Soon Stale Type: Bug WG: components
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

On a page using [`amp-web-push`](https://amp.dev/documentation/components/amp-web-push/), when a user clicks on the `amp-web-push-widget` button a pop-up window is opened. The browser's push notification permission request is made from this popup which loads a permission dialog page.

Presumably the key reason for the popup is so that an AMP page served from an AMP Cache will be able to install the origin site's service worker and issue the permission request from the origin domain, even though the user initiated the push notification subscription from a page served on the cache.

However, is this popup window needed when the AMP page is being served on from origin (or via SxG)? Opening popups seems like it should generally be avoided if possible. If there is no technical reason for the popup on non-cache AMP pages, can `amp-web-push` have logic to issue the permission requests from the AMP page's current window directly without the popup when on origin?

This will become more of an issue as more sites go AMP-first and/or roll out SxG.

Screencast from @jeffersonrabb showing the current popup behavior on a page served from origin: https://cloudup.com/cyyfKRs0tG7 (source: https://github.com/Automattic/newspack-plugin/pull/417)

Contributor guide

Open the contributing guide

Research direction

Start by tracing the amp-web-push widget's permission-request flow and how it distinguishes AMP Cache pages from pages served on origin or through SxG. Confirm whether origin or SxG pages can request permission in the current window without losing service-worker installation behavior, then verify that the popup remains where it is required and is removed where it is not.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.