Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49083

Schedule a local notification 2 days before a date (selected by the user)

$
0
0

Hello
I have an application coded with ionic 3 which must record the date of an event, then remind the user (via local notifications) 2 days before the event and the day before the event.
when i run the code below i don’t get any error, but i also don’t see my notification when i try to list all registered notifications with this.localNotifications.getAll ();

I get the date using this: <ion-datetime displayFormat="DD MMM YYYY à HH:mm" pickerFormat="D MMMM YYYY HH:mm" [(ngModel)]="myDate" name="tokoss"></ion-datetime>

then I create the notification as well

myDate : Date ;
setNotification(){
    var date = new Date(this.myDate);
    date.setDate(date.getDay()-2); //back for 2 days
    console.log(date);
    this.localNotifications.schedule({
      id: 1,
      text: 'Single Local Notification 2 days',
      trigger: { at: new Date(date) },
      data: { secret: 'secret' }
    });
  }

how to fix this problem please

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 49083

Trending Articles