OneSignal / OneSignal-WordPress-Plugin

OneSignal is a free push notification service for web and mobile apps. This plugin makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
80 stars 42 forks source link

No unsubscribe button in AMP version #255

Open Zabi09 opened 4 years ago

Zabi09 commented 4 years ago

Hello Jason and Team,

I am one of the developers of the AMPforWP plugin and currently, some of our users saying that the one signal unsubscribe button is no more visible after clicking on the subscribe button. See this video - https://monosnap.com/direct/VKlLw5V40vY1QbwuJynXSNjYu6n6QY

And also when I check the same on cloudways its a valid issue - https://wordpress-123147-847862.cloudwaysapps.com/faq-test/amp/

I have debugged a lot and finally found that there is some problem in service-worker-url or in helper-iframe-url and if I remove the code of yours of amp-web-push and add this code which I copied from the AMP https://playground.amp.dev/ then it's working fine

This is the code which is not working

<amp-web-push
id="amp-web-push" l
ayout="nodisplay"
helper-iframe-url="https://wordpress-123147-847862.cloudwaysapps.com/wp-content/plugins/accelerated-mobile-pages/includes/onesignal-integration/amp-helper-frame.html?appId=d46c313e-cc91-4d55-b809-1b41b836d57c"
permission-dialog-url="https://wordpress-123147-847862.cloudwaysapps.com/wp-content/plugins/accelerated-mobile-pages/includes/onesignal-integration/amp-permission-dialog.html?appId=d46c313e-cc91-4d55-b809-1b41b836d57c"
service-worker-url="https://wordpress-123147-847862.cloudwaysapps.com/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKWorker.js.php?appId=d46c313e-cc91-4d55-b809-1b41b836d57c">
</amp-web-push>

==========

This is the code which is working fine

<amp-web-push
id="amp-web-push"
layout="nodisplay"
helper-iframe-url="https://amp.dev/documentation/examples/components/amp-web-push/amp-web-push-helper-frame.html"
permission-dialog-url="https://amp.dev/documentation/examples/components/amp-web-push/amp-web-push-permission-dialog.html"
service-worker-url="https://amp.dev/documentation/examples/components/amp-web-push/sw.js" >
</amp-web-push>

==========

Will you please check once and let us know.

MohammedKaludi commented 3 years ago

Any update on this issue? @rgomezp @jasonpang

rgomezp commented 3 years ago

Howdy y'all, Thanks so much for your patience.

I dug into this and the issue seems to be around the helper-frame scope.

As you can see, the amp HTML shows the following in a test app I set up:

<amp-web-push id="amp-web-push" layout="nodisplay" helper-iframe-url="/wp-content/plugins/accelerated-mobile-pages/includes/onesignal-integration/amp-helper-frame.html?appId=a2bbb0ab-a15c-4c20-ba2d-dc06a6a6449b" permission-dialog-url="/wp-content/plugins/accelerated-mobile-pages/includes/onesignal-integration/amp-permission-dialog.html?appId=a2bbb0ab-a15c-4c20-ba2d-dc06a6a6449b" service-worker-url="/wp-content/plugins/onesignal-free-web-push-notifications/sdk_files/OneSignalSDKWorker.js.php?appId=a2bbb0ab-a15c-4c20-ba2d-dc06a6a6449b" class="i-amphtml-element i-amphtml-layout-nodisplay i-amphtml-built" hidden="" i-amphtml-layout="nodisplay"> </amp-web-push>

You will notice that the helper frame is on a different path than the service worker. The problem is that the service worker scope needs to be at an equal or higher scope to include the helper frame path.

Please fix this issue in your plugin and I think we should see it working.

Edit: not only is the button not working, from what I can tell the subscription isn't working either. So the OneSignal integration is currently completely broken with your plugin. Are you seeing otherwise? (e.g: can you send a test message and receive it successfully?)

rgomezp commented 3 years ago

@Zabi09 , Please see my note above.

For HTTP integrations, it looks like our os.tc helper frame is outdated and needs to be fixed on our side. Thanks for your patience while we try to resolve.

Cheers