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
Fix prompting again after closing notification permission prompt if site has its own ServiceWorker.
Details
This PR fixes two things related to this issue:
requestNotificationPermission() - this was always returning undefined due to a conversion bug
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
[X] All the automated tests pass or I explained why that is not possible
[X] I have personally tested this on my machine or explained why that is not possible
[X] I have included test coverage for these changes or explained why they are not needed
Programming Checklist
Interfaces:
[X] Don't use default export
[X] New interfaces are in model files
Functions:
[X] Don't use default export
[X] All function signatures have return types
[X] Helpers should not access any data but rather be given the data to operate on.
Typescript:
[X] No Typescript warnings
[X] Avoid silencing null/undefined warnings with the exclamation point
Other:
[X] Iteration: refrain from using elem of array syntax. Prefer forEach or use map
[X] Avoid using global OneSignal accessor for context if possible. Instead, we can pass it to function/constructor so that we don't call OneSignal.context
Screenshots
Info
Checklist
[ ] I have included screenshots/recordings of the intended results or explained why they are not needed
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:
undefined
due to a conversion bugValidation
Tests
Added a unit test for
requestNotificationPermission()
, this was always returningundefined
before the changes in the first commit.Checklist
Programming Checklist Interfaces:
Functions:
Typescript:
Other:
elem of array
syntax. PreferforEach
or usemap
context
if possible. Instead, we can pass it to function/constructor so that we don't callOneSignal.context
Screenshots
Info
Checklist
Related Tickets
This change is