receiving a broadcast that notification needs to be shown
receiving broadcast that device has been rebooted and notifications have to be rescheduled
Two changes not related to the bug:
Logging when reboot message is received, so it can be debugged whether it's app issue, or Android did not send app the message (which does happen on some devices)
Give a 10 minute slack when rescheduling after boot. With Android pushing towards inexact alarms, notifications showing a couple minutes late is becoming a norm, so rescheduling should to some degree match. 10min is chosen arbitrary, we don't want to show notifications that expired a long time ago.
Developer testing:
Unity trunk only (should not matter aside that trunk only supports Android 6, while older versions support 5.1)
Main test project from the package repo
Scenarios:
Notifications scheduled to arrive after some time do arrive with app in foreground, background or completely killed
Scheduled after reboot notification (dedicated button in project) arrives after device reboot
Devices tested with no issues:
Nokia 7 Plus (10.0)
Pixel 5 (13)
Galaxy S22 (12)
OnePlus6T (9.0)
Asus ROG Phone (8.1)
Testing request:
Android only
Try same scenarios on more devices, especially lower Android versions
When testing reboot, capture logcat for all processes and search for "resched", if the app doesn't print anything, it's a device issue (launching app quickly may be a solution); it is known that some devices don't work well in this scenario.
Some devices have auto-start feature. App may be have auto-start disabled for it by default and experience issues because of that. Assu ROG had this and I would not get notifications after reboot of if app is killed. Enabling auto-start for app resolved the problem.
https://github.com/Unity-Technologies/com.unity.mobile.notifications/issues/271 It is not advised to do IO on Android UI thread, as that may take time and lead to ANRs. Solution is to offload the work onto a background thread. There are two places where the issue is present:
Developer testing:
Testing request: