-
Notifications
You must be signed in to change notification settings - Fork 115
AMP Advanced Setup
If your web push site has subscribers from multiple origins, for example:
- https://your-old-subdomain.onesignal.com
- https://your-old-subdomain.os.tc
- https://push.your-site.com
- https://your-site.com
(in any combination, or with other sites)
then you'll need to follow this modified AMP web push setup guide.
-
Compile a list of origins (examples above), where:
a) Users have existing subscriptions on these sites
b) The site is being actively used as a OneSignal app to send notifications
c) And the site is not your main site where new users are subscribing to
For example, a new HTTPS site using our native web push flow would not need to follow this guide, because the site's users would only be subscribed to:
This violates rule C, and there are no other legacy origins where users are subscribed.
On the other hand, an old HTTP site using a subdomain of OneSignal to send notifications fits the two criteria above, because users are subscribed to:
However, we handle the HTTP sites using our notification domain, so HTTP users don't have to follow this guide.
If your website was previously an HTTP site using our notification domain, and then upgraded to HTTPS while still wanting to share subscribers from your old HTTP site, this guide is for you! In this case, your origins are:
-
For non-onesignal.com and non-os.tc origins, download the file below and upload it to each origin in step 1. The file does not need to be at the site root, but it's easiest if you place it there.
For example, if users have existing push subscriptions on
https://push.your-old-site.com
, you would make the file available onhttps://push.your-old-site.com/amp-remote-frame.html
. -
Download the file below and modify the URLs near the bottom of the script.
For each origin you listed from step 1, add them to the list, followed by the path to the
amp-remote-frame.html
file you uploaded. Add?appId=YOUR-APP-ID
to the end of the URLs following the two example URLs. ReplaceYOUR-APP-ID
with your app ID.If some of the URLs are subdomain.onesignal.com / subdomain.os.tc, keep the two existing URLs but replace
your-old-subdomain
andYOUR-APP-ID
with the correct values for your app. -
Upload the amp-multiple-helper-iframe.html file from the previous step to your main website only. This is the site where new users are getting subscribed.
For example, if new users are being subscribed on
https://new-site.com
, the files should be available athttps://new-site.com/amp-multiple-helper-frame.html
andhttps://new-site.com/amp-permission-dialog.html
only.It shouldn't be any site on the list from step 1.
-
Download the file below and upload it to your main website only.
Just like the step above.
-
Follow our AMP web push setup guide, but replace step 4 in the guide with the modified instructions below.
-
Instead of following step 4 in the original AMP setup guide, add the following initialization HTML code to your AMP page in the
<body>
section:<amp-web-push id="amp-web-push" layout="nodisplay" helper-iframe-url="https://YOURDOMAIN.COM/amp-multiple-helper-frame.html?appId=YOUR-APP-ID" permission-dialog-url="https://YOURDOMAIN.COM/amp-permission-dialog.html?appId=YOUR-APP-ID" service-worker-url="https://YOURDOMAIN.COM/OneSignalSDKWorker.js?appId=YOUR-APP-ID" > </amp-web-push>