-
Notifications
You must be signed in to change notification settings - Fork 114
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 each origin that you own and control (not the onesignal.com or os.tc origins), download the file below and upload it to the origin. 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.htmlfile you uploaded. Add?appId=YOUR-APP-IDto the end of the URLs following the two example URLs. ReplaceYOUR-APP-IDwith your app ID.If some of the URLs are subdomain.onesignal.com / subdomain.os.tc, keep the two existing URLs but replace
your-old-subdomainandYOUR-APP-IDwith the correct values for your app. -
Download the files below and upload it only to your main website. Upload it to the website where new users are getting subscribed. It shouldn't be any site on the list from step 1. The files do not have to exist at the root of your site; you can add the files to subdirectories.
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.htmlandhttps://new-site.com/amp-permission-dialog.htmlonly. -
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>