I'm trying to send a notification based on some parameters and I tried to use a for loop and setTimeout but when i run it all notifications are sent at once. The code looks like this:
this.times is an array of n dimension. this.timer is a variable based on user input
for(let i of this.times) {
this.localNotification()
}
localNotification() {
setTimeout(() => {
this.date = new Date()
this.localNotifications.schedule({
text: "Hey it's time to take a picture",
trigger: {at: new Date(new Date().getTime())},
led: 'FF0000',
sound: 'file:/storage/emulated/0/media/audio/notifications/CwtChime.ogg'
})
this.notificationList.unshift({Title: "Time to take a picture", Body: "Hey, it's been a week since you took a picture, please take one", Reminder: true, Time: `${this.date.toLocaleString()}`, Seen: false})
}, this.timer*1000)
}
when i try to run it all notifications are sent at once and i'm having truble understending how to do it differently.