question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: LocalNotifications are not persisted between device reboot on Android

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
tntwistcommented, Jun 1, 2020

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

2reactions
MedaiP90commented, Jun 6, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Local notifications get lost after android reboot - Ionic Forum
Hey Team, The local notifications in my App get lost after I'm ... here : bug: LocalNotifications are not persisted between device reboot...
Read more >
xamarin - Local Notification Does not Show After Device Reboot
I hate to delete a question from the internet. The issue on boot received was using dependency injection in the boot receiver.
Read more >
Fix an Android device that's restarting or crashing
Go to the next step. If the problem does not go away, skip to Advanced troubleshooting. Step 3: Restart your phone normally &...
Read more >
Android Companion 2022.2: Local Push Notifications!
A persistent notification lets Android know the app has important ongoing tasks where we do not want the background process stopped.
Read more >
Notifications - Expo Documentation
On Android, this module requires permission to subscribe to device boot. ... If you are not using Expo's push notification service and would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found