-
Notifications
You must be signed in to change notification settings - Fork 49
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
.NET MAUI and AOT compilation #258
Comments
@kalpasrl |
My csproj is:
What is the way to exclude FirebaseMessagingService from trimming? |
Ok, so it's indeed trimming (PublishTrimmed), not AOT (RunAOTCompilation), which is causing trouble. I've described the same issue here: #144 (comment) The easiest workaround is to skip trimming for the Plugin.Firebase.CloudMessaging assembly: |
Thank you @tranb3r RunAOTCompilation cannot be used without PublishTrimmed=true |
This workaround no longer works for me. I'm not sure why. I believe I had trimming enabled with the TrimmerRootAssembly excluding Plugin.Firebase in my csproj file and it had working in the past, but not now. I've tried RootMode="Library" as well with no luck. I am forced to disable trimming completely until this issue is fixed with Firebase. |
What did you change? |
I updated Visual Studio. I tried all sorts of recommended variations to get the trimming to leave Plugin.Firebase or Plugin.Firebase.Messaging alone, but it no longer works. My issue is, when trimming is enabled, I do get a notification from Firebase, but it's as if my app is in the background even though I have it in the foreground. I have logic built in to ignore the notifications from OnMessageReceieved if my app is in the foreground and certain pages are focused. With trimming enabled, OnMessageReceived is ignored completely and I get the notification as if my app isn't open at all. Trimming off, works fine, but only if I turn it off completely. |
@jfversluis |
I’ve gotten it to work in release by using these settings in the csproj:
|
Isn't that just turning off AOT Compilation and Trimming for everything? |
Correct, but it was the only way for me to get it to run properly. If a better way presents itself I'll gladly hop aboard. Spent enough time trying to fix strange Maui quirks. |
Yeah, I'm in the exact same boat. Just wanted to make sure I understood correctly. |
@angelru |
I'm also having the issue, I think. To be clear I think there's a clear distinction of what is and what isn't working. Could everyone confirm we're having the same issue? With trimming on the following breaks for me ("publishtrimmed" set to true, along with aot, but also with aot off)
The only thing that works:
They all work fine when trimming is disabled along with aot. I've even tried "linker issues free" .net 9 preview 3, but that still has the issue . (And some other issues of course) @angelru @kalpasrl could you please confirm which of these cases are working for you? I've also taken the liberty to file an issue here dotnet/android#8940 |
@jkommeren |
@jkommeren @kalpasrl |
So thats by using the DynamicDependency attribute right? I'll try it right away when I get home! |
I think there are two ways to preserve this service (both are working):
|
Thanks man, it looks like I'm getting there! The TrimmedRootAssembly suggestion entry did not seem to do anything (maybe because trim was set to full by default? I just put it into an item group in csproj like this (I had done it previously for another dependency that failed because it was trimmed) ... But adding the DynamicDependency |
It should definitely work with full trimming mode. And actually, it's not needed if you do not trim in full mode.
You're welcome. |
@jkommeren
|
Here's the obvious question: are you creating your notification channel? I set up mine in the MainApplication.cs's OnCreate . (Which is also executed at startup of Android, and only once (?) but some people set it up in the Main activity) After that you would need to inform the plugin what the channel id is that you just created.
Check https://github.com/coop-tim/maui-sample/blob/main/MauiSample/Platforms/Android/MainActivity.cs For an example. Just in case you didn't do it 😅 |
I found the problem, the registration to the channel was done in the wrong place in the app. |
You're welcome. Thanks for posting back! |
In our project if I use the release configuration in Android, the compilation is done in AOT and in this case push notifications are not received.
Is there a problem with trimming assemblies?
Plugin.Firebase.CloudMessaging version 2.0.4
Thank you
The text was updated successfully, but these errors were encountered: