6

Sto sviluppando un app con Cordova e sto usando questo plugin per programmare una notifica locale ogni giorno alle ore 6 https://github.com/katzer/cordova-plugin-local-notificationsSchedule una notifica locale ogni giorno con PhoneGap Cordova

tutto funziona bene, questo è il codice che sto usando per impostare de notifica

/*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, 
    }); 

stavo facendo il test, e appare la notifica ogni giorno alle 18:00, ma solo per 9 giorni consecutivi e poi si ferma apparire. Che cosa sto facendo di sbagliato?

Grazie

risposta

7

Anche se il suo ritardo, provare quanto segue al: 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" 
}); 

Per tomorrow_at_6_am si può provare il seguente:

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);