-
Notifications
You must be signed in to change notification settings - Fork 3.7k
"notificationclick" not triggering in Chrome Foreground #268
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
Comments
@talha5389 you could use the |
Doesn't seem to work. Also, I tried calling |
For some reason, changing
to
causes notificationclick event to trigger correctly even in chrome foreground. I am not sure why adding timeout could cause it to work |
I'm not sure why that would help but glad you found a solution. This does look like an issue with browser notifications though and not FCM so I'll close this. |
@kroikie does firebase add is there any example of payload that works? |
I tried adding timeout but still notification click event did not trigger. Please can someone advice. |
here is code using in service worker to add notificationclick event...works fine in Edge. self.addEventListener('notificationclick', function (event) { |
@talha5389 Not sure it will help, but have a look at this doc from google. In my case it was lifesaving! |
@talha5389 I have got same issue, Btw when browser is closed, in other words app is on the background, i get push notification twice, If you have any experience and solve this problem, please help me. Thanks. |
in android chrome not working redirect to url, i don't know have to do. if you have any experience and solve this problem, please help me. Thanks. |
It has been resolved in this comment |
Still not working correctly... |
Browser: Chrome
Browser version: 70.0.3538.102
Operating system: Windows 10
Operating system version: v1803
firebase-app.js: 5.5.8
firebase-messaging.js: 5.5.8
What is the expected result?
When push notification is clicked, its event handler gets called irrespective of whether page is in foreground or background.
What happens instead of that?
I observed following behaviour with "notificationclick"
Details
I want to redirect user to a specific url on notification click. For that, I have implemented "notificationclick" event in service worker as below
I am showing notification using following code
It doesn't seem to be getting called or printing any logs.
Things I have tried
It only seems to be not working in Chrome when site is in foreground. I have tried Edge and firefox. After some tweaking I was able to get desired results on them but not able to found why it isn't working in chrome.
The text was updated successfully, but these errors were encountered: