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

Fix prompting again after closing notification permission prompt if site has its own ServiceWorker #1192

Closed jkasten2 closed 2 months ago

jkasten2 commented 2 months ago

Description

1 Line Summary

Fix prompting again after closing notification permission prompt if site has its own ServiceWorker.

Details

This PR fixes two things related to this issue:

  1. requestNotificationPermission() - this was always returning undefined due to a conversion bug
  2. getRegistration() - did not check if the service worker was a OneSignal one, resulting in wrong assumptions being made.

Validation

Tests

Added a unit test for requestNotificationPermission(), this was always returning undefined before the changes in the first commit.

Checklist

Programming Checklist Interfaces:

Functions:

Typescript:

Other:

Screenshots

Info

Checklist


Related Tickets



This change is Reviewable