How to migrate my website to Batch?

Here is everything you need to know on how to migrate your tokens from your current web push provider to Batch.

If you are already using web push notifications with another provider, then you probably want to migrate your existing userbase to Batch. The methodology described below will allow you to transfer to Batch all users who are already subscribed to notifications on your website.

Migrating your userbase

The user's tokens will be migrated to Batch as they return to your website, and they will not be requested to provide push permission again.

1. Remove the existing configuration

A. Code on the website pages

Remove the code used to initialize the SDK of the previous web push provider, and any code calling its functions.

B. Service worker

Keep the existing service worker file, on its current scope, without modifying it.

By keeping the file untouched, the previous service worker will not be updated until the user returns to the website and will still be able to display a push notification. See the Accelerate the migration part below for more details.

2. Integrate Batch into your website

Accelerate the migration

The previous configuration remains cached until users return to the website. This means that you can send push campaigns from your old tool in addition to the push notifications sent with Batch. This will allow you to continue to address your entire opt-in base while accelerating the migration process:

  • New users and those who have already returned to the website will be targeted by Batch notifications, as their token is attached to the new Batch web push project, and the push will be interpreted and displayed by the Batch service worker.

  • Old opt-in users who have not yet returned to the website will be targeted by the notifications of your previous tool, because their token is still attached to the old web push project, and the notification will be displayed by the service worker of the previous provider.

Can I import a file with all my existing tokens?

A service worker is a script that your browser runs in the background, separate from a web page. This is what will display the push notification.

The web push format does not allow to import the tokens at once as for mobile apps.

Each service worker expects information in non-standard fields (e.g., title, description, etc.) to display the message contained in the received notification. These fields are different for each provider, and there can only be one service worker on a website.

As long as the user has not returned to the site, the SDK and service worker of the previous provider are still running. If this user is targeted by a notification sent from Batch, the notification would be badly displayed or not displayed at all, because it will be interpreted by the service worker of the previous provider.

Testing the migration

Once the integration is complete, you can verify that the migration is successful and that the old tokens are attached to the new Batch web push project.

Here are two simple steps to follow:

  • Subscribe to push notifications on your website before Batch goes live, with the old configuration

  • Go back to the website after the release of Batch, then send yourself a test push from the dashboard. Here is how to do it: How can I send a test notification to my web browser?

If the push is well received, it means that the push token has been attached to the new Batch web push project.

Congrats, you can now use Batch to its full potential 🚀

Last updated

Was this helpful?