-1

FCM documentation states that when app is in foreground, FCM messages are delivered to system tray.

I want to handle these messages in a FirebaseMessagingService. Is it possible to access the system tray to get the firebase messages (as I've already a scheduled Service) or to reactivate the FirebaseMessagingService.onMessageReceived behaviour as on older firebase API versions?

Zohaib Amir
  • 3,482
  • 2
  • 11
  • 29
Nico Hennrich
  • 214
  • 2
  • 10

2 Answers2

1

onMessageReceived is called only when the when there is no notification attached to the message. So for messages with both notification and payload, it won't be called.

According to FCM documentation:

onMessageReceived is provided for most message types, with the following exceptions:

Notification messages delivered when your app is in the background. In this case, the notification is delivered to the device’s system tray. A user tap on a notification opens the app launcher by default.

Messages with both notification and data payload, when received in the background. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.

As you can see, onMessageReceived is called even if your app is in background.

Community
  • 1
  • 1
Zohaib Amir
  • 3,482
  • 2
  • 11
  • 29
0

The messages disappeared on a Xiaomi device due to power saving restriction. After changing batterie management settings data messages arrived

Nico Hennrich
  • 214
  • 2
  • 10