New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(firebase_messaging): ensure silent foreground messages for iOS are called via event channel. #8635
Conversation
Silent/data notifications while the app is foregrounded still did not work for me (tested with firebase_messaging 11.4.0 that has this patch merged). I was able to trace the problem to the
As I am logging the contents of the notiticationDict at that point, I see that it does not at all contain an
This seems to fix the issue for me. |
11.4.0 doesn't work for me neither |
Give
|
@hugovangalen well I believe it's more of a data model issue than just a condition issue |
@PapyElGringo - How are you sending the message? (i.e. nodeJS admin SDK or REST API, etc) |
@hugovangalen - this won't work because it will fire twice on |
@russellwheatley I use Nodejs Admin SDK in firebase functions
|
Right okay, I see. I guess I got distracted by the comment above the condition that says "if alert is present, this will be called by the other "Messaging#onMessage" channel handler", which lead me to think that it only dives in this specific routine for data only messages. If the payload has a notification, it goes through another handler Anyways, yeah, @PapyElGringo may be right in the 'aps' getting stripped somewhere down the line. (I also noticed that "to" field gets stripped from the "data" payload, but that is probably another issue altogether.) The 'userInfo' dictionary does contain the 'aps' payload, so the 'aps' gets lost here:
(I am using the REST API by the way, with a similar payload as PapyElGringo posted above though without an 'alert' property because it's basically a silent control message to send to the UI.) |
I erroneously thought that the notificationDict is what gets delivered by the operating system to the app, yesterday I overlooked the call to [FLTFirebaseMessagingPlugin remoteMessageUserInfoToDict:userInfo] which is where the problem arises, 'aps' is present in userInfo, but not in the resulting dictionary. In fact, in remoteMessageUserInfoToDict, this is happening:
It seems that the 'aps' intensionally gets stripped. It kinda does make sense to strip it, as it is operating system specific data that doesn't need to end up in the Flutter app, but it does break the condition back in didReceiveRemoteNotification. @russellwheatley I suspect that in stead of notificationDict, the userInfo should be tested in line 489: |
@russellwheatley I use |
@PapyElGringo Could you please cconfirm that for you, when you dump the |
My background notifications are blocked because of quotas and priority |
@hugovangalen thanks for the investigation. I will double check and get back to you on this 🙏 |
Hey @hugovangalen, you're correct, apologies for the mistake. I've created a PR which rectifies the issue #8759. Will get this released at some point this week 🙏 |
Description
see title.
Related Issues
fixes #8548
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
).This will ensure a smooth and quick review process. Updating the
pubspec.yaml
and changelogs is not required.///
).melos run analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?