0

I want to know why Firebase Cloud Messaging doesn't send notifications when the app is running?

I started my application and tried to send a message. When I closed my application, it notified me. But when and I opened it and sent another notification, it didn't notify me, but it did trigger onMessage.

Is it possible to notify me when my application is running?

stevenspiel
  • 5,775
  • 13
  • 60
  • 89
Wisit Phusi
  • 451
  • 6
  • 13

1 Answers1

2

Firebase Cloud Messaging has two types of messages: notification messages and data messages.

Data messages are used for delivering data to your app. They are always delivered to your application's onMessage handler.

Notification messages are used to show a notification to the user. When your app is active, the messages are delivered to its onMessage handler, so that you can display the notification inside the app. But when the app is not active, notification messages are handled by the system and not delivered to your app's onMessage handler.

It sounds like you're sending a notification message. If you always want the message to be delivered to your applications onMessage, you should send a data message instead.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807