Skip to content
Jason Pang edited this page Aug 31, 2017 · 2 revisions

Multiple legacy subdomains on an HTTPS site

Introduction

If your web push site has subscribers from multiple origins, for example:

(in any combination, or with other sites)

then you'll need to follow this modified AMP web push setup guide.

Procedure

  1. 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:

  2. 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 on https://push.your-old-site.com/amp-remote-frame.html.

  3. 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. Replace YOUR-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 and YOUR-APP-ID with the correct values for your app.

  4. 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 at https://new-site.com/amp-multiple-helper-frame.html and https://new-site.com/amp-permission-dialog.html only.

  5. Follow our AMP web push setup guide, but replace step 4 in the guide with the modified instructions below.

  6. 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>

Clone this wiki locally