cordova-plugin-local-notifications icon indicating copy to clipboard operation
cordova-plugin-local-notifications copied to clipboard

Repeated notifications problem

Open mschristo opened this issue 6 years ago • 8 comments

Repeated notifications are not working as expected

Your Environment

  • Plugin version: 0.9.2
  • Platform: Android
  • OS version: 8
  • Device manufacturer / model: Pixel XL3
  • Cordova version (cordova -v): 8.0.0
  • Cordova platform version (cordova platform ls): 7.1.2
  • Plugin config: Installed by cli as described on README
  • Ionic Version (if using Ionic) 3

Expected Behavior

Schedule a notification to trigger every time the date time match

Actual Behavior

The notification is triggered in the right time but it shows up multiple times at the same minutes and the app crashes

Steps to Reproduce

I set this:

cordova.plugins.notification.local.schedule({
            title: 'Happy Birthday!!!',
            trigger: { every: { month: 1, day: 17, hour: 12, minute: 20 } }
        });

Context

What were you trying to do?

Debug logs

  • Android: $ adb logcat
01-17 12:20:01.099 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.100 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.150 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.150 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.193 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.193 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.233 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.233 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.268 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.268 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.297 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.297 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.326 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.326 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.354 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.354 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.381 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.381 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.416 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.416 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.442 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.442 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.475 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.475 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.513 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.513 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.560 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.561 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.594 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.595 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.626 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.626 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.653 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.653 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.680 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.681 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.717 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.717 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.727   690   690 E VibratorService: Setting amplitude  to: 3596
01-17 12:20:01.749 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.749 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.775 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.775 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.804 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.804 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.834 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.834 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.860 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.861 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.894 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.894 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.923 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.923 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case
01-17 12:20:01.952 29262 29262 W Notification: Use of stream types is deprecated for operations other than volume control
01-17 12:20:01.952 29262 29262 W Notification: See the documentation of setSound() for what to use instead with android.media.AudioAttributes to qualify your playback use case

mschristo avatar Jan 17 '19 11:01 mschristo

I'm having the same issue, if you find a solution or workaround could you please share?

coleweusthem avatar Jan 17 '19 16:01 coleweusthem

I also have similar issue, just want a repeating notification 'every day' (at whatever time) - works on IOS but not on Android

robertfriston avatar Jan 18 '19 09:01 robertfriston

@mschristo @coleweusthem I'm trying to reproduce this but I can't manage to reproduce it with the given example in this issue.

I used the exact same code as mentioned, only changed the day to the current date and see the following in the adb logs: image

Notification gets triggered only once (which is correct) and the logs show that the next trigger will be in 2020, which is also correct.

Uninstall your app completely and try a fresh install. This will wipe any notification channels created earlier (from the original plugin). Since this fork supports mulitple channels you can create your own channels, so try to define a channel in your notification too while your at it.

@robertfriston Could you provide your JS code so I can test it as well? Perhaps I can reproduce the error with your code.

Steffaan avatar Jan 30 '19 13:01 Steffaan

Hello @Steffaan,

thank you for your answer but i still having troubles making this works. Can you please share your project that this functions works (i assume it's an example code project). Also i cannot see the "next trigger..." log in my logcat

mschristo avatar Jan 30 '19 14:01 mschristo

@mschristo

Sure, it's an empty cordova project where I added the plugin and your code snippet

https://ufile.io/binhc

(don't forget to change the time of the notification)

Steffaan avatar Jan 30 '19 14:01 Steffaan

In your cordova project it's running as expected. But in my ionic project it did not. Here is my project in case you want to take a look:

https://ufile.io/m9zmk

When the notification triggers, it runs multiple times until the app crash. Here is a screenshot of this : notifications

mschristo avatar Jan 31 '19 10:01 mschristo

In case this helps I have never been able to get "Every" working, not in this fork or the original branch. I manually create my schedule (ie each scheduled task) and then refresh that schedule as time goes by. Still even in Android 8 after the first 1 or 2 notifications (across 1 or 2 days) it stops. I am trying it now in this fork to see if works.

gotters avatar Feb 10 '19 13:02 gotters

Here's the bug report for the same issue from the original source: https://github.com/Steffaan/cordova-plugin-local-notifications

Before people start going on about setting count - I'll say it again adding count does not work (it doesn't get used when every is present) when you have repeats so stop putting it forward as a solution - IT DOES NOT WORK FOR THAT USE CASE.

JoueBien avatar Jan 19 '22 11:01 JoueBien