Plugin.LocalNotification icon indicating copy to clipboard operation
Plugin.LocalNotification copied to clipboard

MAUI 8 release mode android: notification is not pushed in 10 seconds from now

Open RpDoc-Christian opened this issue 1 year ago • 6 comments

Hello,

when I want to push a local notification in android in 10 seconds from now it will be delivered and work fine in debug builds but not in release builds. In release the local notification will not be pushed.

A local notification witch shall be delivered directly work in both build conditions.

To Reproduce Steps to reproduce the behavior:

Build and start the sample project in debug mode
Push button to get notification directly
Notification will be delivered
Push button to get notification in 10 seconds
Notification will be delivered
Build and start sample project in release mode
Push button to get notification directly
Notification will be delivered
Push button to get notification in 10 seconds
Notification will NOT be delivered

Expected behavior The notification shall be delivered after 10 seconds in release mode too, not only in debug

Platform (please complete the following information):

OS: Android 34

Smartphone (please complete the following information):

Device: Google Pixel 6a
OS: Android
Version 14

A sample project is attached.

Project is .NET MAUI 8 in Visual Studio 2022 Version 17.10.5 and Plugin.LocalNotification Version 11.1.4

LocalPushNotificationTest.zip

RpDoc-Christian avatar Aug 12 '24 14:08 RpDoc-Christian

we have the same issue. Notifications are scheduled but not displayed at certain time in release mode. For debug mode everything works correctly. We see the following log in logcat: SendNotification: Notification {notificationId} has no NotifyTime It seems to go from here: https://github.com/thudugala/Plugin.LocalNotification/blob/master/Source/Plugin.LocalNotification/Platforms/Android/ScheduledAlarmReceiver.cs#L90 But we surely pass notifyTime to the request and it works in debug mode.

Any updates here?

NaZeRhal avatar Sep 10 '24 13:09 NaZeRhal

Hi, I have a similar situation, also on Android, where my notifications simply stop being sent, even though they exist.

I could be wrong, but maybe this topic makes some sense about the "Wake Lock" functionality on Android

Link: https://stackoverflow.com/questions/75892669/xamarin-maui-app-still-goes-to-sleep-even-though-told-not-to

Kaayo avatar Sep 19 '24 15:09 Kaayo

I have the same problem, everything works fine on debug, but on release stops working for android. Has anybody found a solution?

IGC-P avatar Oct 08 '24 17:10 IGC-P

we have the same issue. Notifications are scheduled but not displayed at certain time in release mode. For debug mode everything works correctly. We see the following log in logcat: SendNotification: Notification {notificationId} has no NotifyTime It seems to go from here: https://github.com/thudugala/Plugin.LocalNotification/blob/master/Source/Plugin.LocalNotification/Platforms/Android/ScheduledAlarmReceiver.cs#L90 But we surely pass notifyTime to the request and it works in debug mode.

Any updates here?

Can you print the NotificationRepository.Current.GetPendingList() at release mode and see what is missing?

It could be an issue with System.Text.Json.Serialization at release mode due to Trimming

#333

thudugala avatar Oct 08 '24 21:10 thudugala

I am using version 10.1.8 and as suggested on #333 , for me it started working on android release mode by adding the following on ProjectName.csproj <ItemGroup> <TrimmerRootAssembly Include="Plugin.LocalNotification" RootMode="library"/> </ItemGroup>

IGC-P avatar Oct 09 '24 20:10 IGC-P

@IGC-P I tested your workaround here in my sample project.

It works now.

But it would be nice if this will fixed in a normal release.

RpDoc-Christian avatar Oct 28 '24 13:10 RpDoc-Christian