Open hhugosz opened 2 years ago
AMP compatibility is a work in progress by @adekbadek at https://github.com/Automattic/newspack-plugin/pull/1076. Last update was half year back.
Hi @hhugosz, this should work in theory – as a plugin file (e.g. wp-content/plugins/newspack-onesignal.php
) – but I haven't tested:
<?php
/**
* Plugin Name: Newspack AMP Plus OneSignal
*/
add_filter( 'newspack_amp_plus_sanitized', function( $is_sanitized, $error ){
if ( isset( $error, $error['type'] ) && 'js_error' === $error['type'] ) {
if (
// OneSignal inline script.
( isset( $error['text'] ) && stripos( $error['text'], 'window.OneSignal' ) ) ||
// OneSignal SDK.
( isset( $error['node_attributes'], $error['node_attributes']['src'] ) && stripos( $error['node_attributes']['src'], 'onesignal.com' ) )
) {
$is_sanitized = false;
}
}
return $is_sanitized;
}, 10, 2 );
@adekbadek Thanks you for sharing code snippets. Will this code also enable/make Prompt & Subscription Bell appear on AMP pages?
It should, yes – though it's been a while since I tested this.
AMP support for OneSignal plugin was released today. Though it may need some improvement.
Thank you for the update, @yogeshbeniwal ! Can you share more about why it may need improvement?
Few of the observations are:
Prompt is not displayed, more important when using standard mode than transitional mode
The only option to prompt for notifications with AMP is amp-web-push-widget
, which only supports a button on the page that must be clicked. Are you asking about the slide down prompt or the browser's native prompt here?
Click on subscription bell results in native browser prompt in new window rather than in same window
There is a AMP feature request for this. https://github.com/ampproject/amphtml/issues/34566
Still shows the subscription bell after users have subscribed, even though setting is to not show.
If you directly accept from this prompt it should be working, so there could be a OneSignal-Wordpress-Plugin bug here. However there is a known limitation where a number of other scarios don't work. https://github.com/ampproject/amphtml/issues/28717
NTG event analytics
Not sure about this one, would need more details.
The only option to prompt for notifications with AMP is
amp-web-push-widget
, which only supports a button on the page that must be clicked. Are you asking about the slide down prompt or the browser's native prompt here?
Asking about slide down prompt.
Not sure about this one, would need more details.
NTG events are specific to events implemented in newspack plugin. Reference here.
Hey guys. As much as the One Signal plugin appears on the approved plugins list, it looks like it needs some special configuration. My site is hosted on Wordpress.Com and is all AMP. Can you help me to implement the plugin?