[firebase_messaging] Disable interception of notification to allow for local notification generation #6113
-
BackgroundI am trying to create a chat app which delivers reliable notifications that includes action buttons such as Unfortunately the The ProblemIf the notification includes the
I have also tested this with my own IOS and Android devices and I would not receive data-only messages unless the app was in the foreground or the last used app on IOS. Notifications would not come through if I was using another app, or it was swiped away from recents. For a chat application, getting reliable messages is a priority and therefore I need to use the
A greater explanation of (number 1):
The Feature RequestI would like to be able to disable the If this is not possible, then I would love to see ActionButtons and Input fields come to the Additional InfromationI created another issue here https://github.com/rafaelsetragni/awesome_notifications/issues/165 Below are the plugin versions I am using at the time of writing this firebase_core: ^1.1.1
firebase_messaging: ^9.1.4 |
Beta Was this translation helpful? Give feedback.
Replies: 36 comments 35 replies
-
I second you on this. We should have a way to prevent the default notification if we'd like to handle some logic onBackgroundMessage() then show the notification. |
Beta Was this translation helpful? Give feedback.
-
Hello, |
Beta Was this translation helpful? Give feedback.
-
A solution to this would be to implement our own onMessage() handler which would allow getting payload from data field and show on the notification. A few guides and leads can be found on this question on stackoverflow |
Beta Was this translation helpful? Give feedback.
-
any update to this problem ? |
Beta Was this translation helpful? Give feedback.
-
Any update!!? |
Beta Was this translation helpful? Give feedback.
-
one year later, the problem is still unresolved. |
Beta Was this translation helpful? Give feedback.
-
Any word on this? |
Beta Was this translation helpful? Give feedback.
-
It looks like the flutter team has decided this will never be implemented: #7874 (comment) |
Beta Was this translation helpful? Give feedback.
-
Its possible to handle the fcm message yourself.
one thing to note is that for the above to work you should send a data only message from your firebase-admin sdk, with the contents of your message as the payload |
Beta Was this translation helpful? Give feedback.
-
I have solved this issue by updating packages to : And add Android Notification Default Channel in AndroidManifest.xml
For More check : I will update this repository, with proper documentation in near future. Hope it will help some one... |
Beta Was this translation helpful? Give feedback.
-
@Minituff I dont think you can use "notification" if you are coding a chat application. Because notifications will display before you have time to decrypt your messages. In case of a chat app, you should use silent (data-only) notification only. This way you can get the payload, decrypt it and use flutter local notification or awesome notification to display a badge. |
Beta Was this translation helpful? Give feedback.
-
Hello guys, just added feature request #9317 |
Beta Was this translation helpful? Give feedback.
-
If there is notification json property in the notifications sent from fcm then default fcm notification will show up.
|
Beta Was this translation helpful? Give feedback.
-
any update? |
Beta Was this translation helpful? Give feedback.
-
firebase_core: ^2.4.0 I'm using this, strill firebase generates a notification by default. Though, I can control custom notification with #flutter_local_notifications: ^12.0.4 |
Beta Was this translation helpful? Give feedback.
-
any update on this, i am also facing same issue from the past 3 days |
Beta Was this translation helpful? Give feedback.
-
As of writing this reply, with |
Beta Was this translation helpful? Give feedback.
-
I work in a bank and as per their new data processing policy, they said you can only send encrypted data in Push Notifications with a custom encryption key, therefore in order to decrypt it at client device I definitely need to show local notifications. |
Beta Was this translation helpful? Give feedback.
-
Any update? I am also facing the same issue from past 7 days. |
Beta Was this translation helpful? Give feedback.
-
data only notification doesn't work for IOS anymore |
Beta Was this translation helpful? Give feedback.
-
Same issue. What notification solution should a E2EE chat app implement where message needs to be decrypted before showing in the notification banner? Background Service was my guess but again it poses unpredictability on iOS. |
Beta Was this translation helpful? Give feedback.
-
it's just a simple thing for the Flutter and Firebase messaging team, just give us a toggle to automatically show notifications on receive or not, and we developers will do the rest of decrypting and issuing our local notifications. I don't understand how difficult it can be for a multi-billion dollar company, very disappointed that after 3 years of this thread, we still have no solution 🤬😡 |
Beta Was this translation helpful? Give feedback.
-
Can someone please try this workaround for IOS? it says we can modify a remote notification and publish our own by using the notification service app extenstion. |
Beta Was this translation helpful? Give feedback.
-
in my case i have done this
take idea from this code this not using awesome notifications flutter packages i am using this package |
Beta Was this translation helpful? Give feedback.
-
hey, any expectations or suggestions about it that made works as expected? |
Beta Was this translation helpful? Give feedback.
-
Hi @felipecastrosales and all, the default notification displays because you included the
|
Beta Was this translation helpful? Give feedback.
-
any update? |
Beta Was this translation helpful? Give feedback.
-
same problem here are there any solutions please ? |
Beta Was this translation helpful? Give feedback.
-
Tried many different solutions, none really worked properly. I ended up with a mixed solution that works for me, while using
then in your To ensure the sound and vibration are working for fcm default notification when the app is in background, specify it in your backend payload :
My 2 cents. Hope it helps someone 👌 |
Beta Was this translation helpful? Give feedback.
-
To prevent notifications from showing when the app is in the background on iOS, your code uses the
Why It Works
This approach ensures a better user experience by preventing unnecessary notifications when your app isn't actively being used.
|
Beta Was this translation helpful? Give feedback.
It looks like the flutter team has decided this will never be implemented: #7874 (comment)☹️