Reputation: 157
I've come across some unexpected issue while using FCM for sending push notifications. I have logged in on my computer and mobile (web), when I hit the button that is responsible for event trigger, the notification pops up but not on the active device. If I hit the button using my mobile, the notification pops up on my computer and not on mobile. Similarly, when I do it using my computer, I'm able to see notification on my mobile and not computer. Is it an issue or this is how it's supposed to be? I'm using Firebase-admin SDK with my Node.js server.
Upvotes: 1
Views: 1287
Reputation: 7388
The push notifications are only shown when your App is not in focus. If you use your App to send a push notification you won't see it there. You can still build your own logic for handling incoming messages while your app has focus using this kind of code:
// Handle incoming messages. Called when:
// - a message is received while the app has focus
// - the user clicks on an app notification created by a service worker
// `messaging.onBackgroundMessage` handler.
messaging.onMessage((payload) => {
console.log('Message received. ', payload);
// ...
});
You can read more about it here.
Upvotes: 2