WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!
Provide a general summary of the issue.
cordova -v
): 8.0.0cordova platform ls
): android 6.4.0There should be a single notification at the specified time, and the nothing until the following minute/hour/day/week
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
// 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);
});
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
Btw, I'm probably gonna use this workaround in the meantime, since it seems to be working somewhat ok.
setNotifications(every: string, firstAt: Date){
let notifications = [];
let n:number = 63; // arbitrary large number
let title: string = "Title";
let text: string = "Text";
for (let i=0; i<n; i++){
let theAt = new Date(firstAt);
if (every == 'minute'){
theAt.setMinutes(theAt.getMinutes()+i);
}else if (every == 'hour'){
theAt.setHours(theAt.getHours()+i);
}else if (every == 'day'){
theAt.setDate(theAt.getDate()+i);
}else if (every == 'week'){
theAt.setDate(theAt.getDate()+i*7);
}
notifications.push(
{
id: i,
title: title,
text: text,
icon: "",
sound: true,
smallIcon: "res://"+this.notificationStrings.icon,
//foreground: true,
wakeup: false,
trigger:{
at: theAt
}
}
);
}
cordova.plugins.notification.local.schedule(notifications,()=>{
console.log("notification set ", firstAt, every);
});
}
Every time the app is started, I cancelAll() and then reset a new set of notifications, making sure that firstAt is at the appropriate time in the future.
Nevermind, it looks like my install script reverted automatically to 0.9.0-beta2 when installing the plugin using @latest . 0.9.0-beta3 doesn't show the repetition behavior.
However, I will stick to using my workaround, because it should work on iOS too where firstAt is not available, and it also restores the notifications after a reboot on android if foreground: true and priority: 1 is set.
Thanks for the plugin!
Actually, I tried again today, and the problem seems to be there on beta3 as well.
Reopening the issue
@alesgenova Please make sure again that you're running beta.3 and provide a working sample. In case of date issues its important to know how the start date and the trigger date correspond together. For example the endless loop happens by setting trigger.at to _now_.
Yes this time I'm sure I'm running beta.3
The code to reproduce it it's the following.
What I expect: I expect a notification to be fired every hour at :00 minutes.
What happens: At the expected time, infinite notifications get triggered (like 2 or more per second), and they keep on firing until the clock turns to :01
let notifications = [
{
id: 0,
title: "title",
text: "text",
icon: "",
smallIcon: "res://"+this.notificationStrings.icon,
wakeup: false,
foreground: true,
priority: 1,
trigger: {
every: {minute: 0},
}
}
]
cordova.plugins.notification.local.schedule(notifications,()=>{
console.log("notification set ");
});
@alesgenova Yes thats a bug in the code for Android and Windows if the minute is lower compared to the base date. However there's no infinite loop. The plugin wont schedule any notification because the calculated date is in the past.
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!
I am getting this error message, This is my code
this.localNotifications.schedule({
id:1,
title:"Reminder",
text:"Please drink water",
priority:2,
trigger:{ every:{minute:30}}
})
trigger: { every: { minute: number; ...' is not assignable to parameter of type 'ILocalNotification | ILocalNotification[]'
I want to get a notification on every 30 minutes.
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,
},
});
This seems to work:
import {LocalNotifications, ELocalNotificationTriggerUnit} from '@ionic-native/local-notifications';
`
let date = new Date(new Date().getTime() + 3600);
this.localNotifications.schedule({
text: 'Local notification',
trigger: {
firstAt: date,
every: ELocalNotificationTriggerUnit.MINUTE,
count: 5,
},
});`
@katzer firstAt is not working on iOS, so how on earth is it possible to trigger a notification on a specific time and then let it trigger every minute from that time unless it's cancelled.
Not working:
this.localNotifications.schedule({
id,
text: title,
trigger: {
at: when.toDate()
},
every: "minute",
});
Not working:
this.localNotifications.schedule({
id,
text: title,
trigger: {
at: when.toDate(),
every: {
minute: 0
},
},
});
Not working:
this.localNotifications.schedule({
id,
text: title,
trigger: {
at: when.toDate(),
every: ELocalNotificationTriggerUnit.MINUTE
},
});
This works, but then it doesn't fire every minute... When using 'at' and 'every' together, the notification does not get scheduled at all.
this.localNotifications.schedule({
id,
text: title,
trigger: {
at: when.toDate()
},
});
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.
@marioshtika I have the same issue. Are you saying that in 0.9.0-beta.3 this issue does not exist and npm version is 0.9.0-beta.2?
Most helpful comment
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!