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
389 stars 115 forks source link

[Bug]: Receives push notification only if tab is closed, can anyone please help me with this one ? #1193

Closed aman-u-7span closed 2 months ago

aman-u-7span commented 2 months ago

What happened?

OneSignal is initialised successfully and there are no error or warnings in browser but this seems to be very weird behaviour as push notifications are received only if tab is completely closed.

What browsers are you seeing the problem on?

Firefox, Chrome (Chromium), Safari

What operating system are you running?

macOS monterey 12.7.1

Steps to reproduce?

- This is the cdn i'm using 'https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.page.js'.
- importScripts("https://cdn.onesignal.com/sdks/web/v16/OneSignalSDK.sw.js") this is inside my service-worker file.

What did you expect to happen?

I expect to receive notifications even if tab is active or inactive.

Relevant log output

No response

dongph9x commented 2 months ago

@aman-u-7span Maybe sw of onesignal conflict with other sw, please move sw of onesignal without root folder. Change scope and path of OneSignalSDKWorker.js Ex: serviceWorkerParam: { scope: "/onesignal/push-notifications/" }, serviceWorkerPath: "onesignal/push-notifications/OneSignalSDKWorker.js",

aman-u-7span commented 2 months ago

@dongph9x I didn't have any other service worker but moving service worker to another folder worked. Thanks mate really appreciate it.