cordova-plugin-local-notifications: Every triggers countless notifications for a minute, then stops - 0.9-beta.3

WARNING: IF YOU IGNORE THIS TEMPLATE, WE’LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue.

Your Environment

  • Plugin version: 0.9-beta.3
  • Platform: Android
  • OS version: 8.1 and 7.1
  • Device manufacturer / model: Nexus 5X
  • Cordova version (cordova -v): 8.0.0
  • Cordova platform version (cordova platform ls): android 6.4.0
  • Plugin config
  • Ionic Version (if using Ionic) 3.9.2, but using the plugin directly, without the ionic-native layer

Expected Behavior

There should be a single notification at the specified time, and the nothing until the following minute/hour/day/week

Actual Behavior

I’m trying to get a daily/weekly notification, but I ran into a bug. When the matching time comes, notifications start firing (i.e. more than one notification per second), until the clock of the phone changes. I fround this issue both using the every match, and every repeat

Steps to Reproduce


// Something like this
let notifications = [
      {
        id: 0,
        title: "title",
        text: "text",
        icon: "",
        smallIcon: "res://"+this.notificationStrings.icon,
        wakeup: false,
        trigger: {
          every: {hour: at.getHours(), minute: at.getMinutes()},
        }
      }
]

// Or even

let notifications = [
      {
        id: 0,
        title: "title",
        text: "text",
        icon: "",
        smallIcon: "res://"+this.notificationStrings.icon,
        wakeup: false,
        trigger: {
          firstAt: at,
          every: "minute",
        }
      }
]

cordova.plugins.notification.local.schedule(notifications,()=>{
      console.log("notification set ", at);
    });

Context

Debug logs

02-13 12:59:00.492  1634  1634 E NotificationService: Muting recently noisy 0|com.tapabit.zest|0|null|10079
02-13 12:59:00.705  1634  1634 I chatty  : uid=1000 system_server identical 29 lines
02-13 12:59:00.710  1634  1634 E NotificationService: Muting recently noisy 0|com.tapabit.zest|0|null|10079
02-13 12:59:00.717  1634  8564 E NotificationService: Package enqueue rate is 5.6015325. Shedding 0|com.tapabit.zest|0|null|10079. package=com.tapabit.zest
02-13 12:59:00.830  1634  1634 E NotificationService: Muting recently noisy 0|com.tapabit.zest|0|null|10079
02-13 12:59:01.833  1634  1634 I chatty  : uid=1000 system_server identical 4 lines
02-13 12:59:02.036  1634  1634 E NotificationService: Muting recently noisy 0|com.tapabit.zest|0|null|10079
02-13 12:59:02.172  2241  9000 E ActivityThread: Failed to find provider info for com.google.android.apps.gsa.testing.ui.audio.recorded
02-13 12:59:02.238  1634  1634 E NotificationService: Muting recently noisy 0|com.tapabit.zest|0|null|10079
--------- beginning of main
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.schedule(Notification.java:206)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Manager.schedule(Manager.java:100)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.localnotification.TriggerReceiver.onTrigger(TriggerReceiver.java:73)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.receiver.AbstractTriggerReceiver.onReceive(AbstractTriggerReceiver.java:65)
02-13 12:59:02.658  8854  8854 W System.err:    at de.appplant.cordova.plugin.notification.Notification.trigger(Notification.java:254)
...

Continues like this for several MB

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 31 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Just use : trigger: { every: { hour: 20, minute: 20, second: 15 }, count: 1 },

it will be fired only once at the right time.

Hope it works 4 u too!

Hello everybody!

I had this problem for a long time and I just found out that the master branch has already resolved this issue. All this time I installed it through package.json so I was using the “0.9.0-beta.3” and “0.9.0-beta.2”

So if you use the repository url in the config.xml file, it will work. Or you can fork the project and make your own release.

@katzer can you please make a release with your latest commits.

Thank you in advance.

To avoid the repeated notifications every second, set “count” to some large number.

cordova.plugins.notification.local.schedule({
  id: 0,
  title: title,
  text: text,
  trigger: {
    firstAt: at,
    every: 'minute',
    count: 1440,
  },
});

I have solved the problem . The problem was the plugin see all the ids is the same if it is not equal mathematically. I have changed the id from Math.random() to new Date().getTime().