-
Notifications
You must be signed in to change notification settings - Fork 68
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
On Android, for repeating notifications, time interval added on every reboot pushing notification further into future. #251
Comments
This was referenced Feb 3, 2022
@c0ff33-b34n without changing if (request.Schedule.NotifyTime < DateTime.Now)
{
request.Schedule.NotifyTime = request.GetNextNotifyTime();
} I was think we should change GetNextNotifyTime from internal DateTime? GetNextNotifyTime()
{
if (IsStillActiveForReSchedule() == false)
{
return null;
}
var repeatInterval = GetNotifyRepeatInterval();
if (repeatInterval is null)
{
return null;
}
if (Schedule.NotifyTime.HasValue == false)
{
return null;
}
var newNotifyTime = Schedule.NotifyTime.Value;
var nowTime = DateTime.Now.AddSeconds(10);
while (newNotifyTime <= nowTime)
{
newNotifyTime = newNotifyTime.Add(repeatInterval.Value);
}
return newNotifyTime;
} |
thudugala
pushed a commit
that referenced
this issue
Feb 4, 2022
…ndroid #251 On Android, for repeating notifications, time interval added on every reboot pushing notification further into future.
@c0ff33-b34n Can you please try version 9.2.0-preview01 |
@c0ff33-b34n Can you please try version 9.2.0-preview02 |
This is now working and the correct time interval is being added in 9.2.0-preview03. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
After rebooting the device repeating notifications have their notification interval added to the notify time, without first checking that the current notification time is in the future. This means that if the device is rebooted multiple times before the notification time is reached, the new notification time is pushed further and further into the future.
For example, if you turn on your device at 7am and had a notification set for 8am, that notification is rescheduled to 8am the next day. Turn the device off and on again and it will move even further into the future and you will only receive the notification it if you leave the device on until it catches up.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I would expect that if a notification time has not yet been reached then it would show that notification at the original set time, and then only add the repeat time interval when that notification is received.
Platform:
Smartphone:
Additional context
The issue seems to be caused when the
BootReciever
class calls request.Schedule.NotifyTime = request.GetNextNotifyTime();
When
request.GetNextNotifyTime();
is called it adds on the repeat interval regardless.In NotificationRequest:
With a downloaded copy of the plugin I wrapped the above code from BootReceiver with a check to see if the alarm time had already passed first.
With the update above it seems to fix the problem.
As an aside I noticed that if I set the repeat interval to only 2 minutes the phone tried to optimize power usage, as did having power save mode switched-on on my device. Even with power saving turned off the device was performing other optimizations, so I had to turn off Battery Optimization for my specific app on the device too. All these Android automatic optimizations / phone manufacturer's 3rd party settings make testing of the underlying code a bit trickier with local notifications, I think something everyone should pay close attention to when using local notifications on Android.
Setting notification repeats to 3 minutes and turning power saving and battery optimization off allowed each repetition of the notification to come through after reboot once changes to the BootReciever code were made in my local copy.
The text was updated successfully, but these errors were encountered: