Automattic / newspack-plugin

An advanced open-source publishing and revenue-generating platform for news organizations.
https://newspack.com
GNU General Public License v2.0
328 stars 49 forks source link

Conflict of PWA and OneSignal (caused by Service Workers) #2104

Open adekbadek opened 1 year ago

adekbadek commented 1 year ago

Describe the bug

Both PWA and OneSignal plugins register their Service Workers, which are in conflict.

This is a known issue (link, link), which is not caused by Newspack. But it can perhaps be solved by this plugin.

To Reproduce

  1. Install PWA and OneSignal plugins on a new WP site
  2. Configure OneSignal
  3. In a new (non-incognito!) session, load the site and subscribe to notifications by clicking the bell icon in the bottom right corner
  4. Send a new notification from the OneSignal dashboard
  5. Observe a notification with "This site has been updated in the background" payload instead of the intended message

Next steps

Delaying the OneSignal initialization, as described here, has worked – but only if OneSignal was initialized well after the PWA Service Worker has been installed & activated. In my testing, a delay of 10s worked, but in production this should be solved by waiting for the SW activation event.

yogeshbeniwal commented 1 year ago

Service Workers for OneSignal was moved to new scope: /push/onesignal/ already to take care of conflict with PWA https://github.com/OneSignal/OneSignal-WordPress-Plugin/pull/268

adekbadek commented 1 year ago

Thanks! Still, the issue is reproducible and it relates to SWs.