1

FCM lets us send push messages with two kinds of payload (notification and data), which are handled differently on Android:

  • notification messages, which contain only notification data
  • data messages, which contain only custom data
  • notification+data messages, which behave differently depending on whether the app is in foreground or not

In the third case, if the app is in foreground, the message is handled by a custom FirebaseMessagingService subclass in onMessageReceived(RemoteMessage). Otherwise, the system (or, more precisely, Google Play Services), builds the push notification.

I'd like to build a notification in onMessageReceived(RemoteMessage) that would be identical to the notification that the system would build if the push was received while the app is dead or in background, ie. taking into account the notification data received in the push (RemoteMessage.Notification), the defaults set in the Manifest's meta-data, etc. Is there a method in the SDK that would allow that, or maybe a third-party library, or do I have to reverse-engineer it by myself?

SpaceBison
  • 2,525
  • 1
  • 21
  • 38

0 Answers0