Using FCM notifications with data payloads leads to potentially confusing results
See original GitHub issue[READ] Step 1: Are you in the right place?
Yes, your people might consider it is a feature request but to me this is clearly a bug due a bad architecture.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: any
- Firebase Component: FCM
- Component version: any
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
When using FCM to push notifications to android devices, developpers need to deal with a 6 posible scenarios described in this table https://firebase.google.com/docs/cloud-messaging/android/receive#handling_messages
the simple fact of having a 6 scenario table for something simple like “push notification” should alread trig an ‘alert’ in any architect mind, but the thing gets worse when we think about the messages with data. they might be delivered to onMessageReceived
and might be to the launcher intent.
so it automatically creates a scenario where the code will be duplicated, two classes will need to deal with same business logic. but this is not the end
follow my logic: 1- app is in background 2- fcm pushes a data+notification message 3- user sees the notification in system tray… and simple ignores it, or even has that kind of notification set to NEVER SHOW on android settings
following this scenario the app WILL NEVER RECEIVE THE DATA FROM THAT NOTIFICATION. since the launcher intent from the notification tray will never be clicked
i dont know what kind of android restrictions lead the engineers decide for this such frankstein behavior but at first glance it could be easily fix
if the android-fcm SDK is able to send the data messages to onMessageReceived
even during background time… why the mixed data+notification could not send the data part also to onMessageReceived
?
imho everything could be sent to that method and this class could implement a very simple method allowing any developper to foward the notifications to system tray from the onMessageReceived
method
this would avoid so much code replication and create a less franksteins behavior
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top GitHub Comments
@bolds07 as I mentioned in https://github.com/firebase/firebase-android-sdk/issues/1818 it’s not acceptable to abuse anyone in the Firebase community (Googlers or other developers like @carlonzo) on GitHub. We’re all here to make Firebase better but that has to start from a place of respect.
Hi, I would like to add a few points to your post: