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: Local notification scheduled not called

See original GitHub issue

Bug Report

Capacitor Version

πŸ’Š   Capacitor Doctor  πŸ’Š 

Latest Dependencies:

  @capacitor/cli: 2.4.7
  @capacitor/core: 2.4.7
  @capacitor/android: 2.4.7
  @capacitor/electron: 2.4.7
  @capacitor/ios: 2.4.7

Installed Dependencies:

  @capacitor/core 2.4.6
  @capacitor/ios 2.4.6
  @capacitor/android 2.4.6
  @capacitor/cli 2.4.6
  @capacitor/electron not installed

[success] Android looking great! πŸ‘Œ
  Found 20 Capacitor plugins for ios:
    cordova-plugin-advanced-http (3.0.1)
    cordova-plugin-app-version (0.1.9)
    cordova-plugin-badge (0.8.8)
    cordova-plugin-device (2.0.2)
    cordova-plugin-file (6.0.2)
    cordova-plugin-file-transfer (1.7.1)
    cordova-plugin-filechooser (1.2.0)
    cordova-plugin-filepath (1.5.8)
    cordova-plugin-globalization (1.11.0)
    cordova-plugin-inappbrowser (4.0.0)
    cordova-plugin-ionic-keyboard (2.2.0)
    cordova-plugin-ionic-webview (4.2.1)
    cordova-plugin-localization-strings (3.2.1)
    cordova-plugin-nativestorage (2.3.2)
    cordova-plugin-statusbar (2.4.2)
    cordova-plugin-whitelist (1.3.3)
    cordova-sqlite-storage (5.0.1)
    cordova.plugins.diagnostic (6.0.2)
    cordova-plugin-androidx-adapter (1.1.3)
    onesignal-cordova-plugin (2.11.2)
[success] iOS looking great! πŸ‘Œ

Platform(s)

Android, iOS

Current Behavior

Schedule notification gets called only once

Expected Behavior

Schedule notification should get called daily

Code Reproduction

let notification: LocalNotification = {
          title: 'title',
          body: 'body',
          id: dailySheduleNotificationIds[i],
          schedule: {
            on: {
              hour: times[i].hour,
              minute: times[i].minute,
            },
          },
          actionTypeId: '',
        };

and the rest with LocalNotifications.schedule

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
daveshirmancommented, Mar 26, 2021

@alphagamer7 I have a problem similar to yours, and the documentation does not describe that well how to handle scheduled notification which repeats e.g. every day at 15:00 (β€œHH: mm”) - at least I can not figure it out.

I got it to work on iOS with the following setup:

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

const notifs = await LocalNotifications.schedule({
  notifications: [
    {
      title: "Title",
      body: "Body text here",
      id: uniqueId,
      schedule: {
        repeats: true,
        every: "day",
        on: { hour, minute },
      },
    },
  ]
});

However, I have not managed to get the same setup to work on Android and I am still looking for an answer on how to make it work on both iOS and Android.

So it might be a bug or else the documentation needs to be updated to better describe how to handle scheduled local notifications that repeats itself every day at a specific time.

I second this, the documentation for this does not explain even the most simple use cases, i.e.

  • Daily repeating at time X - e.g. every day at 15:00
  • Specific day repeating at time X - e.g. every thursday at 09:00

These should be in the docs at a bare minimum.

2reactions
lpilcommented, Jun 5, 2021

I too am having an issue with this. It would be wonderful to get this cleared up, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ios - Local notifications are scheduled, but not delivered in ...
However, it works perfectly only when the app is in the background, not suspended or not running state. In those states I get...
Read more >
Scheduling and Handling Local Notifications - Apple Developer
You schedule local notifications at a time when your app is running either in the foreground or background.
Read more >
Notifications - Expo Documentation
Notifications. The expo-notifications provides an API to fetch push notification tokens and to present, schedule, receive and respond to notifications.
Read more >
Scheduling local notifications - a free Hacking with iOS
iOS has a framework called UserNotifications that does pretty much exactly what you expect: lets us create notifications to the user that ...
Read more >
flutter_local_notifications | Flutter Package - Pub.dev
A cross platform plugin for displaying and scheduling local notifications for ... not report the correct number of scheduled notifications if it is...
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