Skip to content

TrimMode=full seems to break android push notifications on MAUI .net 9 preview 3 #8940

Closed
@jkommeren

Description

@jkommeren

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

  1. Create project in .net 9 preview 3
  2. Add firebase push notification support via Xamarin.Firebase.Messaging" Version="123.3.1.1", google-services.json, etc.
  3. Create a channel with priority max or high, ask for permission to send notifications
  4. Build project in release mode, setting PublishTrimmed to true (and AOT on or off, no difference)
  5. Deploy it to Android device
  6. Launch application
  7. Send notification via Firebase Console with application open, specifying the channel
  8. 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.

Metadata

Metadata

Labels

Area: LinkerIssues when linking assemblies.needs-triageIssues that need to be assigned.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions