cordova-plugin-local-notifications: Trigger notifcation happen multiple times

Your Environment

  • Plugin version: lastest
  • Platform: Android
  • OS version: 7.1
  • Device manufacturer / model: Samsung Galaxy S7 Edge
  • Cordova version: 7.1.0
  • Cordova platform version: android 6.3.0
  • Plugin config: trigger schedule
  • Ionic Version (if using Ionic): 1.3.0

Expected Behavior

Notification should happen once only on trigger time

Actual Behavior

Notifcation non-stop fire repeatedly in about 5 minutes then stop

Steps to Reproduce

This is my code in app.js. I use ionic v1 with ngCordova

  $ionicPlatform.ready(function() {
	cordova.plugins.notification.local.schedule({
		id: 1,
		title: 'test title',
		text: 'test description',
		trigger: { every: {hour: 10, minute: 0, second: 0} }
	});

Context

Fire notication at specific hour every day like 10 am and 4pm every day

Debug logs

Include Android logs

12-14 04:06:04.015 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.017 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.018 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.019 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.020 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.021 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.022 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.023 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.024 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.025 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))
12-14 04:06:04.026 30007-30007/io.ionic.starter D/CordovaWebViewImpl: >>> loadUrl(javascript:cordova.plugins.notification.local.core.fireEvent("trigger",{"id":1,"title":"test title","trigger":{"every":{"hour":4,"minute":5,"second":0},"type":"calendar"},"actions":[],"attachments":[],"autoClear":true,"defaults":0,"foreground":false,"groupSummary":false,"launch":true,"led":true,"lockscreen":true,"number":0,"priority":0,"progressBar":{"enabled":false,"value":0,"maxValue":100,"indeterminate":false},"showWhen":true,"silent":false,"smallIcon":"res:\/\/icon","sound":true,"text":"","vibrate":false,"wakeup":true,"meta":{"plugin":"cordova-plugin-local-notifications","version":"0.9-beta"}},{"event":"trigger","foreground":true,"queued":false,"notification":1}))

A lot of them

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 5
  • Comments: 32 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Now I could reproduce. It happens when the components matches now and no count is specified.

I came across this issue today on an HTC M9 running Android 7.0 with . While adding count will stop the spamming it does not allow the notification to have any repeats (using every doesn’t work when you add count). an example where adding count fails to solve the problem:

        cordova.plugins.notification.local.schedule({
          title: 'message',
          trigger: {firstAt: time2, every: "minute", count:1},
          foreground: true,
          id: 2
        });

In this case the notification is only fired once and then notifications don’t get repeated every minute afterwards. I would suggest reopening this issue because:

  1. the “just add count” workaround is not a slution to this problem -> it dosen’t work in all uses cases.

  2. Commit b93cf65 which is marked as the fix for this issue dose not solve this issue either.

Should be fixed now. Please reopen otherwise. You can use the master branch version or set count: as a workaround.


There’s no second property for every - It has always a zero value.

Same issue here every: { hour: 16, minute: 11} notification comes multiples times at 16.11

@JoueBien and @mschristo , I was having the same problem here, so I changed “count” for 30, the multiple notifications didn’t happen and it repeated for the next 2 days (Didn’t test more). Probably will repeat for the next 30 days. One trick could be rescheduling the notification every time the user opens the app. Actually this is a nice feature to not repeat infinitely if the app is not being used. 🗡

Hey @katzer, thanks for your quick reply and fix!

I tried to add count and it works perfectly if I schedule the notification to trigger immediately (only trigger once), but if I want it to trigger in a few minutes, it doesn’t work. Tried with 2 minutes and 5 minutes. Still working on iOS though.

Tried both with v 0.9.0-beta.2 and with latest version (commit 63c99d3ea1eb9a902fb9f1d121bdd99a243a45eb)

Example:

cordova.plugins.notification.local.schedule({
  id: 100,
  foreground: true,
  title: 'my title',
  text: 'my text',
  trigger: {
    count: 1,
    every: { weekday: 4, hour: 10, minute: 28 }
  }
})

This would work if I make the scheduling at Thursday 10.28, will trigger immediately. But if I schedule it at Thursday 10.27 (for 10.28), it is not triggered.

I have another confirmed case of this.

The ionic wrapper (@ionic-native/local-notifications v4.17.0) is not compatible with the latest versions of this plugin (beta 2 or beta 3). As a result, we are using the cordova plugin directly.

When using the cordova plugin directly:

  • using every: { minute: 55 } will fire notifications indefinitely while the clock reads “xx:55”
  • using count: 1 will only fire 1 notification, but it prevents the recurrence

If we come up with a solution, I will be sure to update this post. It is maddening how fragile this ionic/cordova universe is.


Edit:

The unfortunate solution we came up with was reverting the ionic plugin AND this plugin back to old versions. We can now use the ionic plugin, and the notifications are recurring as expected.

"@ionic-native/local-notifications": "4.6" "de.appplant.cordova.plugin.local-notification": "^0.8.5"

You need to use 0.9-beta.3 or at least these commit.

@katzer Tested with Your latest fix, works like a charm.

I really appreciate Your fast reply and hard work on this plugin!

Cheers Unkn0wn0x