Reputation: 8742
Is it possible to send data payload through Firebase Console that we can receive in onMessageReceived()
while our app is in background/killed?
Upvotes: 12
Views: 5784
Reputation: 6699
It doesn't seem like the Firebase Console has the option to send "data" type messages. If you set the custom data fields in the Firebase Console, those will be delivered but only if your app is in the foreground. You need to implement your own FCM sender or use a 3rd party to send data type messages.
See this answer for more details about the two types of Firebase messages
Upvotes: 2
Reputation: 9225
Yes! but :)
When your application is in the background notification messages (which is what is sent from the console) are automatically displayed in the system tray. When the user taps on the notification the custom data is made available in the intent of the Activity that is launched.
Note that if the user never taps the notification there is no way to get at that data, so this data should not be critical for your application to function but should be used to enhance the user's experience once they have tapped the notification.
As you may have realised if your app is in the foreground, onMessageReceived is called and you can retrieve the custom data there.
Upvotes: 1