简体   繁体   中英

Firebase Cloud Messaging doesn't notify when application is running

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?

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM