9
votes

I am trying to migrate to Firebase cloud messaging from GCM and I noticed that when the application is not running the notifications are coming in the notifications tray. With GCM this was not the case, it was up to the developer to show a notification or not. I want to have similar behavior with FCM where when the app is running I want to silently handle the push message instead of having user to click on the notification and start the app. How can I achieve that.

Thanks, P

1

1 Answers

9
votes

Firebase Cloud Messages has two types of messages:

  1. Notification Message: this type of message has the same behavior as the GCM messages

FCM automatically displays the message to end-user devices on behalf of the client app. Notification messages have a predefined set of user-visible keys

  1. Data Message: this type has the behavior you described above.

Client app is responsible for processing data messages.
Data messages have only custom key-value pairs.

To send data messages you need to use the HTTP API [for Data Message]. (quoted from Arthur)

Full documentation: https://firebase.google.com/docs/cloud-messaging/concept-options