-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: OneSignal.Notifications.addEventListener('click'.....)
- event is fires dozens of times when app starts.
#970
Comments
Hi @kpturner, It may be related to the HMR so your However, they shouldn't fire if no notification is clicked. What exactly prints in the You can also try removing the |
The async isn't relevant I'm afraid. The function awaits an async function after receiving the event. I removed it in the example but forgot to remove the async on the definition. But it wouldn't make any difference here. The event received is actually a real event from a clicked notification - but it was only clicked once much earlier today. I redeployed the app on the emulator which broke the cycle. As I said I can see why it's adding multiple listeners but I am not sure why it's firing the event multiple times 🤷♀️ it |
Each time the anonymous listener is added, it is added to a queue of listeners. When the click event is processed, it fires all the listeners with the event. If you add this listener 5 times, all 5 will trigger with the same information. |
But why would it fire the click event at all if no notification has been clicked? It's as if the event is stored somewhere and every time there is an HMR something decides to fire the event again. |
Confirming that this only happens when HMR is in affect. |
Confirm |
What happened?
I hope this is a symptom of a development environment only, but when I define the listener below the click event fires dozens of times when the app starts up without any notification actually being clicked. This us a
vue
application usingnuxt
and so has a HMR function for development. It is possible that the listener is being added over and over again - but it doesn't explain why it fires over and over again (providing the exact same event every time).Steps to reproduce?
What did you expect to happen?
The event should only fire if a notification is clicked.
OneSignal Cordova SDK version
5.0.4
Which platform(s) are affected?
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: