12

Is it possible to send data payload through Firebase Console that we can receive in onMessageReceived() while our app is in background/killed?

Image.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Hisham Muneer
  • 8,558
  • 10
  • 54
  • 79

2 Answers2

2

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

Community
  • 1
  • 1
ashishduh
  • 6,629
  • 3
  • 30
  • 35
1

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.

Arthur Thompson
  • 9,087
  • 4
  • 29
  • 33