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
[Fix] notification click event not firing if it opens a new tab #1132
Fix notification click event not firing if it opens a new tab.
Details
The internal fireStoredNotificationClicks() function was not called to fire any pending click events when OneSignal.Notifications.addEventListener('click', function() {}) is called.
Validation
Tests
Tested on Chrome 119 on Window 11, testing both "focus" and "navigate" options for notification open behavior.
Click behavior set on dashboard "Origin: Take actions on a previous tab open to same domain"
Click behavior set on dashboard "Exact: (default) Opens a new window"
Info
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
Tested click Behavior Exact:
Tested click behavior Focus:
Info
Checklist
[X] I have included screenshots/recordings of the intended results or explained why they are not needed
Description
1 Line Summary
Fix notification click event not firing if it opens a new tab.
Details
The internal
fireStoredNotificationClicks()
function was not called to fire any pending click events whenOneSignal.Notifications.addEventListener('click', function() {})
is called.Validation
Tests
Tested on Chrome 119 on Window 11, testing both "focus" and "navigate" options for notification open behavior.
Info
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
Tested click Behavior Exact:![image](https://github.com/OneSignal/OneSignal-Website-SDK/assets/645861/cf5d831c-92e0-44b7-8546-45f5f94d4a98)
Tested click behavior Focus:![image](https://github.com/OneSignal/OneSignal-Website-SDK/assets/645861/894d54c4-2748-41dc-855d-e112391ee94e)
Info
Checklist
Related Tickets
This change is![Reviewable](https://reviewable.io/review_button.svg)