Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Migrate to a Different Web Push Notification Platform

DZone's Guide to

How to Migrate to a Different Web Push Notification Platform

Learn how websites operating on HTTPS protocol can migrate their notification subscribers from one web push notification platform to the other without losing a significant base.

· Web Dev Zone
Free Resource

Tips, tricks and tools for creating your own data-driven app, brought to you in partnership with Qlik.

We are asked this question almost on an everyday basis at iZooto. In this post, I will cover how websites operating on HTTPS protocol can migrate their notification subscribers from one web push notification platform to the other without losing a significant base. The process differs for Chrome, Firefox, and Safari. Let’s discuss each of these in detail.

Chrome and Firefox

You've probably read about Chrome allowing developers to handle offline experiences and background syncs on web pages for managing push notifications to engage with web visitors with the help of service workers. Service worker is a background script that owns and controls the web pages of the domain where it’s installed. Firefox also manages push subscriptions through service worker.

How Does the Subscription Work?

web push notification platform

To understand the subscriber migration process, you need to understand the basics of notification subscription. Let’s take a step back to understand what happens in the background.

Whenever a user visits a web page, he or she is prompted to subscribe to push notifications. A service worker is registered for the domain and it manages communication through push notifications for subscribed users further. Whenever a notification is due against a subscriber, a service worker takes over, gets the notification content, displays it to the subscription, and redirects him or her to a landing page.

Nomenclature for service workers may differ from one vendor to other. At iZooto, we refer to it as service-worker.js. It’s usually placed at the root directory. Please note that service workers are supported on HTTPS domains only. Websites operating on HTTP typically end up taking subscriptions on a third party domain. For instance, an HTTP website http://myonlineshop.com would take subscriptions on https://myonlineshop.izooto.com with default configuration on iZooto.

Hygiene Checks
web push notification platform

Domain Ownership

Every subscription is tied to the domain the user is subscribed to. Hence, it’s critical that the subscriptions are taken on your own domain and not on someone else’s. For HTTPS websites, this part is taken care with the implementation as subscriptions are taken on the same domain. HTTP websites should ensure that subscriptions are taken on their own domain or a sub-domain. Users should subscribe to https://www.yourwebsite.com or https://notify.yourwebsite.com and not to https://yourwebsite.serviceprovider.com.

Subscriber Ownership

Ensure that you are using your own GCM/FCM Sender ID for Chrome. All notifications pushed to Chrome subscribers flow through the FCM project configured; it’s critical that you create and own this project.

Subscription Domain FCM Details (For Chrome) Migration Possible?
https://myonlineshop.com

Your own

Yes. Repeat users can be migrated.
https://myonlineshop.com


Vendor’s



No


https://notify.myonlineshop.com

Your own

Yes. Repeat users can be migrated.
https://notify.myonlineshop.com

Vendor’s

No

https://myonlineshop.izooto.com

Your own

No

https://myonlineshop.izooto.com


Vendor’s



No


A unique subscriber key is generated for each "Allow" action, which is used to send notifications against. All the users who click "Allow" become a part of your subscriber base.

Migration and the Finer Nuances

Once you have finalized the new service provider, here is what you need to do:

  1. Check the file name of the old service worker.
  2. Rename the service worker file of the new provider.
  3. Update the service worker js.

What About New Visitors?

The moment you go live the updated service worker, manifest and Javascript on your website, web push notifications are activated again and new users will be prompted as usual. Nothing changes here.

What about the users who have already subscribed to notifications? Will they be prompted again? No. Your old subscribers will not be prompted for subscriptions. In the background, the service worker registered on the user’s browser will get updated. What this means is that you will be able to send notifications using the new service provider.

There is no way that you can migrate all the subscribers at a single shot. As your old subscribers visit your website, your old subscribers will automatically get migrated to the new platform and their numbers should start reflecting. This means you will now be able to send notifications to these subscribers using the new service provider.

You can use both the tools to send notifications. However, it’s not recommended, as sending notifications from the older vendor might bring migrated users back. You should always send notifications from the newer tool.

How long it will take to migrate all subscribers depends completely on your share of repeat traffic. The higher your repeat traffic, the faster the migration. This also depends on the repeat frequency.

Your subscribers will not get two notifications. As the domain to which subscribers are linked remains the same, subscribers won’t receive same notification twice.

Safari

web push notification platform

Safari push notifications are supported for both HTTP and HTTPS sites on OS X. Subscriptions are linked to an APN push certificate and to an end-point URL on which subscriptions are stored. Ensure that you create the required APN certificate through your own Apple developer account.

Here’s how to generate APN for your domain.

Explore data-driven apps with less coding and query writing, brought to you in partnership with Qlik.

Topics:
migrations ,web dev ,push notifications ,tutorial

Published at DZone with permission of Pravya Pravin. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}