So… I have been losing my mind with this over the last few days. I’m using the Local Notifications plugin and I need to send the notifications after scheduling them to a specific time. Such as scheduling the notification to 5h30am and then repeat it every 12 hours.
schedulePushNotification(id, date : Date, message: string, repeat = -1, endDate: Date = undefined, includeTime: boolean = false){
var datetime = date;
if(!includeTime){ //Set time to 9am if time is irrelevant
datetime.setHours(9);
datetime.setMinutes(0);
}
//Cancel notification if it exists.
this.localNotifications.cancel(id).then(()=>{
if(repeat > 0){
if(endDate != undefined){
this.localNotifications.schedule({
id: id,
text: message,
trigger: {firstAt: datetime, in: repeat, every: ELocalNotificationTriggerUnit.SECOND, before: endDate},
foreground: true
});
}
What is wrong with this? I tried with just “at” instead of firstAt but didn’t do anything as well. Also, I read on the plugin’s github that firstAt isn’t supported on iOS. How should I approach this issue then, without the firstAt?
If it’s relevant, the problem is to notify the user to take her medicine, after selecting the date and time she took it and the period of the medicine should be applied again.
1 post - 1 participant