thank you for your reply. now i can create a local notification and it runs at the scheduled time. but when i try to schedule multiple notifications, some go and some don’t. here is my code
let date = new Date(this.myDate);
let twoDaysAgo = addDays(date, -2);
let oneDaysAgo = addDays(date, -1);
// 2 days ago first notification
twoDaysAgo.setHours(6,0,0);
this.localNotifications.schedule({
id: new Date().getTime(),
text: 'local notification 2 days ago 6h',
trigger: { at: twoDaysAgo },
data: { secret: 'secret' }
});
// 2 days ago 2nd notification
twoDaysAgo.setHours(8,0,0);
this.localNotifications.schedule({
id: new Date().getTime(),
text: 'local notification 2 days ago 8h',
trigger: { at: twoDaysAgo },
data: { secret: 'secret' }
});
// 2 days ago 3rd notification
twoDaysAgo.setHours(15,0,0);
this.localNotifications.schedule({
id: new Date().getTime(),
text: 'local notification 2 days ago 15h',
trigger: { at: twoDaysAgo },
data: { secret: 'secret' }
});
// 1 days ago 1st notification
oneDaysAgo.setHours(6,0,0);
this.localNotifications.schedule({
id: new Date().getTime(),
text: 'Local notification one day ago 6h',
trigger: { at: oneDaysAgo },
data: { secret: 'secret' }
});
// 1 days ago 2nd notification
oneDaysAgo.setHours(8,0,0);
this.localNotifications.schedule({
id: new Date().getTime(),
text: 'Local notification one day ago 8h',
trigger: { at: oneDaysAgo },
data: { secret: 'secret' }
});
// 1 days ago 3rd notification
oneDaysAgo.setHours(15,0,0);
this.localNotifications.schedule({
id: new Date().getTime(),
text: 'Local notification one day ago 15h',
trigger: { at: oneDaysAgo },
data: { secret: 'secret' }
});
when i run it i have the following issues:
- the first and second notifications do not run at the scheduled time (6 a.m. for the first and 8 a.m. for the second), but run at the same time with the 3rd (scheduled for 3 p.m.)
- when its change from “twoDayAgo” to oneDayAgo, all oneDayAgo notificatons are executed at the same time as the first (scheduled at 6h)
please what’s the problem with my code?