Closed jkasten2 closed 2 years ago
Hi @jkasten2 👋 At Newspack, we're very keep to integrate OneSignal, and handling AMP in this plugin (instead of our workaround) seems like the best way forward. Is this planned to be implemented?
Howdy y'all, It's been a while since we revisited this issue thread so I just wanted to check-in.
The plugin now automatically supports AMP (see PR). From the Newspack team, have you tested the latest plugin version? I believe it should work automatically but please let us know if there is other work needed to fully support the integration.
@adekbadek
Thanks for checking and for adding compatibility! We have a number of people using the latest version with AMP-compatibility, and it's been working well for them so far.
If there is one feature request we can make it would be to have the AMP version respect the left/right settings from the WP Admin options screen. Currently it's hard-coded to the right corner. Totally not a big deal or hurry though. Feel free to close this issue. :)
Certainly! Great to hear it's working well.
I'll create a separate issue for the placement improvement.
Thanks for opening that issue regarding bell placement! https://github.com/OneSignal/OneSignal-WordPress-Plugin/issues/291
Scope
Creating this issue to track and discuss how to make AMP web push compatible with
Automattic/newspack-plugin
andOneSignal-WordPress-Plugin
.Status
276, released in 2.2.6.
<amp-web-push>
Tag DetailsThanks to @westonruter for these details Example of the
amp-web-push
component, configured with a custom element like so:And then there are two custom elements for subscribing and unsubscribing to the notifications:
Integration TODO:
Thanks again to @westonruter for these details So for configuration with OneSignal, I think it's mainly a matter of just supplying the relevant URLs to
<amp-web-push>
. See an example in the Newspack plugin's yet-unmerged PR https://github.com/Automattic/newspack-plugin/pull/417 which seeks to add AMP-compatible push notifications. Theamp-web-push
attributes could be set accordingly:helper-iframe-url
: https://github.com/Automattic/newspack-plugin/blob/4ef2275b580e230392a77a1c2b84d3bdc58e53b8/includes/raw_assets/html/amp-web-push-helper-frame.htmlpermission-dialog-url
: https://github.com/Automattic/newspack-plugin/blob/4ef2275b580e230392a77a1c2b84d3bdc58e53b8/includes/raw_assets/html/amp-web-push-permission-dialog.htmlservice-worker-url
: https://github.com/Automattic/newspack-plugin/blob/4ef2275b580e230392a77a1c2b84d3bdc58e53b8/includes/raw_assets/html/amp-web-push-service-worker.jsservice-worker-scope
: Since the OneSignal service worker no longer needs to control the page, then this could be a path to wherever the script is located (instead of/
).So when
amp_is_request()
returnstrue
, then that component could be rendered on the page. Iffalse
(or the function is not defined), then the plugin could continue doing what it does at present inOneSignal_Public::onesignal_header()
.See also https://github.com/OneSignal/OneSignal-WordPress-Plugin/issues/258.