6

Tôi đang phát triển một ứng dụng với cordova và tôi đang sử dụng plugin này để sắp xếp một thông báo địa phương mỗi ngày để 06:00 https://github.com/katzer/cordova-plugin-local-notificationsSchedule thông báo địa phương mỗi ngày với PhoneGap cordova

Tất cả mọi thứ hoạt động tốt, điều này là mã mà tôi đang sử dụng để thiết lập 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, 
    }); 

tôi đang làm thử nghiệm, và thông báo xuất hiện mỗi ngày lúc 6 giờ chiều nhưng chỉ trong 9 ngày liên tiếp và sau đó ngừng xuất hiện. Tôi đang làm gì sai?

Cảm ơn

Trả lời

7

Mặc dù cuối của nó, hãy thử như sau tại địa chỉ: 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" 
}); 

Đối tomorrow_at_6_am bạn có thể thử như sau:

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); 
Các vấn đề liên quan