Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase Cloud Messaging Android receive silent push notifications

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

like image 734
user2622786 Avatar asked Jun 30 '16 23:06

user2622786


People also ask

How do I send silent push notifications?

Control Panel. To send a Silent Push Notification to your mobile app, check the checkbox Silent Push in the iOS and Android push settings of the Send Push form.

What is silent notification in FCM?

When a silent notification is sent through firebase, the android app can handle the notification both in the foreground and background. Silent notifications can however not be handled on iOS, neither in the foreground or background, the app doesn't get any indication of the app receiving the notification.

Is Firebase Cloud Messaging push notifications?

Firebase Cloud Messaging (FCM) provides a reliable and battery-efficient connection between your server and devices that allows you to deliver and receive messages and notifications on iOS, Android, and the web at no cost.


1 Answers

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

like image 76
Diego Giorgini Avatar answered Oct 05 '22 02:10

Diego Giorgini