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
onMessage() not fired when app is in background (Web javascript). #641
Comments
Same problem. I'm getting "this site has been updated in the background" I'm using Reac.js Any one can help? |
Facing the same problem. |
I believe the firebase web documentation is not very clear. In my case the onMessage and onBackgroundMessage were explicitly fired. It was either one or the other. What I did was, I setup a communication channel between the app and the service worker using the Client API. |
I suspect the issue might be stemming from the Firebase Cloud Messaging (FCM) SDK, which automatically displays notifications when your app is in the background. If, in addition to this, you are manually triggering a notification inside the onBackgroundMessage handler, it would result in duplicate notifications being displayed In the documentation can see this Docs |
I building a simple demo chat app with fcm integrated for new message notification. As far as I know, in fcm doc regarding
onMessage()
, it said this method get called when:(1) a message is received while the app has focus
(2) - the user clicks on an app notification created by a service worker
messaging.onBackgroundMessage
handler.But I'm not sure why
onMessage()
callback is not fired when my app is in background.Step 1: Describe your environment
Step 2: Describe the problem:
onMessage()
callback is not fired when my app is in background.Steps to reproduce:
Observed Results:
onBackgroundMessage()
from sw.js get called fine, but when I clicked on the notification to land on my app window,onMessage()
did not get triggered (it's only triggered when the current browser window is in foreground state). It did not show any error or warning.Expected Results:
onMessage()
should be fired after I clicked the notification to have my app focused.Relevant Code:
this is my index file
this is my sw.js
Note: I need to comment
self.registration.showNotification(notificationTitle, notificationOptions);
to avoid the notification got duplicate.Any help on this would be much appreciated...
Thank you.
The text was updated successfully, but these errors were encountered: