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?
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.
The messages disappeared on a Xiaomi device due to power saving restriction. After changing batterie management settings data messages arrived
FCM message will show in system tray if your app is in background but if your app is in foreground your FirebaseMessagingService.onMessageReceived will trigger so you can show a dialog or snackBar.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.