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

bug: LocalNotifications are not persisted between device reboot on Android #2830

Closed
meltuhamy opened this issue Apr 26, 2020 · 11 comments · Fixed by #3027
Closed

bug: LocalNotifications are not persisted between device reboot on Android #2830

meltuhamy opened this issue Apr 26, 2020 · 11 comments · Fixed by #3027

Comments

@meltuhamy
Copy link

meltuhamy commented Apr 26, 2020

Bug Report

Capacitor Version

npx cap doctor output:
💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 2.0.1

@capacitor/core: 2.0.1

@capacitor/android: 2.0.1

@capacitor/electron: 2.0.1

@capacitor/ios: 2.0.1

Installed Dependencies:

@capacitor/electron not installed

@capacitor/cli 2.0.1

@capacitor/core 2.0.1

@capacitor/ios 2.0.1

@capacitor/android 2.0.1

[success] Android looking great! 👌
Found 0 Capacitor plugins for ios:
[success] iOS looking great! 👌

Affected Platform(s)

  • Android

Current Behavior

Local notifications that have been previously shceduled on Android aren't triggering after the device re-boots.

Expected Behavior

Local notifications that have been previously shceduled on Android should trigger after the device reboots.

Sample Code or Sample Application Repo

Sample app: I've created a new ionic app, here's the scheduling code: https://github.com/meltuhamy/cap-local-notification-persistence-bug/blob/master/src/pages/Home.tsx

import { Plugins } from '@capacitor/core';
const { LocalNotifications } = Plugins;

LocalNotifications.schedule({
  notifications: [
    {
      title: "Title",
      body: "Body",
      id: 1,
      schedule: { at: new Date(Date.now() + 1000 * 60 * 5) },
      sound: null,
      attachments: null,
      actionTypeId: "",
      extra: null
    }
  ]
});

Reproduction Steps

  1. Schedule a local notification (using the snippet above) to be 5 minutes in the future. This should be enough time to reboot the device.
  2. Once the notification is scheduled, reboot the device.
  3. Wait for the notification to trigger (even though the app has not started)
  • Expected: the notification should trigger.
  • Actual: the notification is no longer scheduled

Other Technical Details

npm --version output: 6.14.4

node --version output: v13.12.0

pod --version output (iOS issues only): N/A

Other Information

It turns out that the notifications have to be re-scheduled on Android, otherwise Android will clear them on device boot.

@jcesarmobile
Copy link
Member

this happens on Android only? you didn't check the platform checkbox

can you provide a sample app?

@jcesarmobile jcesarmobile added the needs reply needs reply from the user label Apr 27, 2020
@meltuhamy
Copy link
Author

Hey, thanks for the reply. I am pretty sure it's Android only. I'll test it on iOS and get back to you. I'll try and create a sample app that repros but it should be as straight forward as what I mentioned in the issue.

@rarespop95
Copy link

I have the same problem. The notifications won't trigger after I reboot the device. I've tested it on Android 10 device and also on emulators(Android 10-7).

@tntwist
Copy link
Contributor

tntwist commented Jun 1, 2020

Same here. Tested on device and emulators (Android 9 and 10).

@MedaiP90
Copy link

MedaiP90 commented Jun 6, 2020

Same problem with android 6 and 9 on phisical devices, this is annoying

@meltuhamy
Copy link
Author

@jcesarmobile I won't be able to provide a sample app soon. In the meantime, this issue has gathered enough feedback to prove it's a real issue. The repro steps are enough to trigger the issue here.

@imhoffd imhoffd removed the needs reply needs reply from the user label Jun 10, 2020
@rakeshprakash91
Copy link

rakeshprakash91 commented Jun 24, 2020

I am building an application, in which one of the key features is scheduling reminders, I faced the same issue in cordova(apparently the bug is open since 2017). Hope capacitor will fix the issue sooner. Since the localNotification is not working after restart, for the time being, I am using calendar events to set the reminder.

@meltuhamy
Copy link
Author

@meltuhamy
Copy link
Author

^ not sure why those labels got added. It's android only.

@XtreZz
Copy link

XtreZz commented Jul 1, 2020

I am also have issues with this. I hope will be fixed soon!

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 11, 2022

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants