Description
Android application type
.NET Android (net7.0-android, net8.0-android, etc.)
Affected platform version
VS 2022 17.10.0 preview 7
Description
Notifications don't arrive in some cases when "PublishTrimmed" is set to true and building it in Release mode (which is the default)
Point is: @jonathanpeppers suggested to create a new issue here if the issue still persisted on .net 9 preview 3. As far as I'm aware it has been an issue at least since .net 7, but also very likely .net 6.
Originally posted by @jonathanpeppers in #5652 (comment)
Also mentioned in dotnet/maui#16014
And at least some people seem to be affected here dotnet/maui#19900
Steps to Reproduce
- Create project in .net 9 preview 3
- Add firebase push notification support via Xamarin.Firebase.Messaging" Version="123.3.1.1", google-services.json, etc.
- Create a channel with priority max or high, ask for permission to send notifications
- Build project in release mode, setting PublishTrimmed to true (and AOT on or off, no difference)
- Deploy it to Android device
- Launch application
- Send notification via Firebase Console with application open, specifying the channel
- Notification does not arrive
Did you find any workaround?
Set PublishTrimmed to False or deploying in debug mode fixes the issue immediately: Then the notification does arrive.
Also one odd thing: When the application is in the background, sending a notification via the Firebase console does pop up.
(But if it's sent as a Data message instead, the FirebaseMessagingService does not pick it up in foreground nor background. That is also fixed by using non-trimming or debug)
Maybe there's something I completely don't understand about Android notifications in MAUI, but the way I understand it, Debug should behave like Release mode in these cases right? And Non-trimmed vs Trimmed in Release mode too?
Relevant log output
There is no log output. No unhandled exceptions. Nothing appears to happen when the notification is supposed to arrive.