Skip to content
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

Android: Scheduled Notification Doesn't Appear After Restart + Relaunch App #2412

Open
jcmtyler opened this issue Sep 24, 2024 · 1 comment

Comments

@jcmtyler
Copy link

jcmtyler commented Sep 24, 2024

Describe the bug
I create a notification using zonedSchedule() and I can see it getting triggered while the app is running after I create it, or after I restart the device (Pixel 5 emulator API 33). However if I restart the device and then relaunch my app, then the notification does not appear. I can see that it's still there both by calling pendingNotificationRequests() and viewing the scheduled_notifications.xml file in shared prefs. If I restart the device again, then the notification will appear. I have reproduced this using my own code and also the sample app from flutter_local_notifications 17.2.2.

To Reproduce

  1. Android emulator running Pixel 5 API 33
  2. Launch the flutter_local_notifications sample app
  3. Changed line 1448 in _zonedScheduleNotification() to create a notification 5 minutes after now (also change buttonText on line 432 to say 'appear in 5 minutes')
  4. Tap button 'Schedule notification to appear in 5 minutes based on local time zone'
  5. Verify that the notification has been saved by tapping 'Check pending notifications' or viewing the scheduled_notifications.xml file
  6. Restart emulator by swiping down from the top twice, tapping the power icon, and then Restart
  7. After restart, launch the sample app
  8. Wait for more than 5 minutes to have elapsed from creating the notification
  9. No notification appears
  10. Verify that the notification still is pending by tapping 'Check pending notifications' or viewing the scheduled_notifications.xml file
  11. Restart emulator again as in step 6
  12. Notification will appear after startup, before launching the sample app

Expected behavior
On step 8 above, I expect the scheduled notification to appear after restart, regardless of whether the app is in foreground or background, or whether it's been launched after restart.

Sample code to reproduce the problem
I have reproduced this using the flutter_local_notifications sample app, v17.2.2, running on a Pixel 5 API 33 emulator.

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.6.1 23G93 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.1)
[✓] Connected device (4 available)
[✓] Network resources

@MaikuB
Copy link
Owner

MaikuB commented Oct 20, 2024

Wasn't able to reproduce this. I took a video but it's too large to upload here so created a link in case you wanted to see. Note the link will expire I'm not sure how you are running the sample app but how I do it is to have the repository cloned. Mentioning this in case you're copying the Dart code, which may miss some of the platform-specific configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants