Schedule a local notification every day with phonegap cordova
Asked Answered
R

1

6

I'm developing an app with cordova and i'm using this plugin to schedule a local notification every day to 6 o'clock https://github.com/katzer/cordova-plugin-local-notifications

Everything works fine, this is the code that i'm using to set de Notification

/*Set 6 o'clock*/
function setTestAlarm() {
    var notify = new Date();
    notify.setHours(18,00,00,00);

  localNotification.add({
        id:      1,
        title:   'My app',
        message: 'Hi this is a notification',
        repeat:  'daily',
        date:    notify,
        autoCancel: true, 
        ongoing: true, 
    });

I was doing testing , and notification appears every day at 6 pm but only for 9 consecutive days and then stops appearing . What am I doing wrong?

Thanks

Rigney answered 11/2, 2015 at 21:44 Comment(0)
T
8

Although its late, try the following at: https://github.com/katzer/cordova-plugin-local-notifications/wiki/11.-Samples

cordova.plugins.notification.local.schedule({
    id: 1,
    text: "Good morning!",
    firstAt: tomorrow_at_6_am,
    every: "day" // "minute", "hour", "week", "month", "year"
});

For tomorrow_at_6_am you can try the following:

var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate()+1);
tomorrow.setHours(6);
tomorrow.setMinutes(0);
tomorrow.setSeconds(0);
var tomorrow_at_6_am = new Date(tomorrow);
Tacita answered 24/4, 2015 at 12:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.