bug: LocalNotifications are not persisted between device reboot on Android
See original GitHub issueBug 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
- Schedule a local notification (using the snippet above) to be 5 minutes in the future. This should be enough time to reboot the device.
- Once the notification is scheduled, reboot the device.
- 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.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (2 by maintainers)
Same here. Tested on device and emulators (Android 9 and 10).
Same problem with android 6 and 9 on phisical devices, this is annoying