Issues in triggering local notification in Ionic 3 at a specific time every day


#1

I’m using localnotifications plugin in ionic 3 in order to get notifications. I want to trigger notification at a particular time everyday. Like if user sets reminder at 10:00 Am today it should automatically trigger every day at the same time until the user updates it next time.

I’ve tried the following code to achieve it but it’s not working.

morningTime: String = '08:15';
date: any = '';

scheduleMorningReminder(){
    this.date = this.datePipe.transform(this.date,"yyyy-MM-dd");
    var reminder_date = new Date(this.date+" "+this.morningTime);

    if(reminder_date){
      this.localNotifications.schedule({
         text: 'This is your notification',
         trigger: {at: reminder_date},
         led: 'FF0000',
         id: 1,
         every: 'day' 
      });
    }
}

my html

<ion-datetime displayFormat="hh:mm A" pickerFormat="h mm A" [(ngModel)]="morningTime" (ionChange)="scheduleMorningReminder()"></ion-datetime>

I have also tried the following code

scheduleMorningReminder(){
    this.date = this.datePipe.transform(this.date,"yyyy-MM-dd");
    var reminder_date = new Date(this.date+" "+this.morningTime);

    var hours = reminder_date.getHours();
    var minutes = reminder_date.getMinutes();
    var pushTime = moment().add(0, 'days').hours(hours).minutes(minutes).seconds(0);

    if(reminder_date){
      this.localNotifications.schedule({
         text: 'This is your notification',
         trigger: {at: pushTime.toDate()},
         led: 'FF0000',
         id: 1,
         every: 'day'
      });
   }
}

Can someone help me with this?

#2

Hello, did You resolve Your issue, becouse I have the same problem :confused: