[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: 27 comments 27 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.
-
This problem still occurs in 2023. |
Beta Was this translation helpful? Give feedback.
-
After a long time, I can able to solve this problem. You just need to remove the notification data from your send message payload and handle everything with data after that you are able to use the custom notification plugin and the notification will only show once. Previous Payload Changed Payload |
Beta Was this translation helpful? Give feedback.
-
Any update on this? Removing notification data is not the solution. |
Beta Was this translation helpful? Give feedback.
-
Hello Friends! I figured out the solution at last!If you are using
If you send this payload from backend then the automatically generated notification will never displayed & you will only see your custom notification with HIGH PRIORITY! Note: I only testing it on Android device because I donot have MAC :) but anyone of you please test it in IOS as well and tell us the behaviour in this thread. Help the community! |
Beta Was this translation helpful? Give feedback.
-
Well it doesn't work like that, FCM ignore null and empty values, it's part
of the json parser only.
If you want to check print the notification payload output in your
onBackgroundMessage or onMessage callbacks
You will get null response for the notification key.
Still if you are confident with this, make sure to test this properly with
a release build with different edge cases like, app minimize, killed, force
stop, battery saver mode
Also print the notification priority payload you will get the idea what
priority FCM sets for data only notification.
…On Mon, 25 Sept, 2023, 11:37 pm Syed-Waleed-Shah, ***@***.***> wrote:
But in this case the notification is not data only. We have provided the
notification object in payload. We just passed null in title and body,
therefore our OS will not treat it as data only notification.
@akshaybengani <https://github.com/akshaybengani>
—
Reply to this email directly, view it on GitHub
<#6113 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFMQ72GQJYWJZHLJ3PWL7P3X4HB4HANCNFSM44XMDQWQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Did you find a solution to this problem? |
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 looks like the flutter team has decided this will never be implemented: #7874 (comment)☹️