OneSignal / OneSignal-Website-SDK

OneSignal is a push notification service for web and mobile apps. This SDK makes it easy to integrate your website with OneSignal Push Notifications. https://onesignal.com
Other
383 stars 115 forks source link

[Question]: Migration Guide for v16 #1172

Closed fresh-avocado closed 1 month ago

fresh-avocado commented 2 months ago

How can we help?

A few years ago I configured One Signal in a website. I added the following script tag on all pages:

<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async />

and I also self-hosted OneSignalSDKWorker.js and OneSignalSDKUpdaterWorker.js. Both have the same file contents:

importScripts("https://cdn.onesignal.com/sdks/OneSignalSDK.js");

According to this migration guide I need to update the script tag to:

<script src="https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js" defer></script>

the contents of OneSignalSDKWorker.js to:

importScripts("https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js");

and rest of the updates: window.OneSignalDeferred = window.OneSignalDeferred || [] and OneSignalDeferred.push((OneSignal) => ...).

Thus, I have the following questions:

  1. What should happen to OneSignalSDKUpdaterWorker.js?
  2. After I make the necessary updates according to the migration guide, will the push notifications still work for my previous subscribers that used the previous SDK version?
  3. Are there any other things that I need to do in order to update the SDK version, but still make it work for old users?

Thank you in advance for your help! 😁

jkasten2 commented 2 months ago

@fresh-avocado Thanks for reaching out.

  1. What should happen to OneSignalSDKUpdaterWorker.js?

This file hasn't been used a while (since version 151510, Nov 22, 2021). However since you may have end-user who haven't visited your site since then to be extra safe I would recommend updating the contains of this file to importScripts("https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js"); as well.

  1. After I make the necessary updates according to the migration guide, will the push notifications still work for my previous subscribers that used the previous SDK version?

yes, pushes will continue to be received and display for all existing subscribers. Even if they don't open your site again after updating.

  1. Are there any other things that I need to do in order to update the SDK version, but still make it work for old users?

No other changes are needed.

fresh-avocado commented 1 month ago

@jkasten2 thank you so much!