0

ion v1で毎日午後8時に通知を送信したい。私は次のコードを参照しましたが、例外があります。ここでは、どの日時フォーマットを使用すべきですか?どこでも完全なコードが見つかりませんでした。私を助けてください。ionic v1で毎日特定の時刻に通知を送信する

hereから

https://github.com/katzer/cordova-plugin-local-notifications/wiki/11.-Samples

document.addEventListener('deviceready', function() { 
// Schedule notification for tomorrow to remember about the meeting 
cordova.plugins.notification.local.schedule({ 
    id: 10, 
    title: "Meeting in 15 minutes!", 
    text: "Jour fixe Produktionsbesprechung", 
    at: monday_9_am, 
    data: { meetingId:"#123FG8" } 
}); 

// Join BBM Meeting when user has clicked on the notification 
cordova.plugins.notification.local.on("click", function (notification) { 
    if (notification.id == 10) { 
     joinMeeting(notification.data.meetingId); 
    } 
}); 

// Notification has reached its trigger time (Tomorrow at 8:45 AM) 
cordova.plugins.notification.local.on("trigger", function (notification) { 
    if (notification.id != 10) 
     return; 

    // After 10 minutes update notification's title 
    setTimeout(function() { 
     cordova.plugins.notification.local.update({ 
      id: 10, 
      title: "Meeting in 5 minutes!" 
     }); 
    }, 600000); 
}); 
}, false); 

/**********Exception***************/ 
ionic.bundle.js:26794 ReferenceError: monday_9_am is not defined 
at Channel.<anonymous> (controllers.js:4672) 
at Channel.subscribe (cordova.js:775) 
at document.addEventListener (cordova.js:133) 
at HTMLDocument.document.addEventListener (cordova.js:1703) 
at controllers.js:4636 
at Scope.$emit (ionic.bundle.js:30645) 
at Object.emit (ionic.bundle.js:58086) 
at transitionComplete (ionic.bundle.js:58032) 
at HTMLElement.completeOnTransitionEnd (ionic.bundle.js:58012) 
at defaultHandlerWrapper (ionic.bundle.js:16787) 

答えて

0

:具体的に

cordova.plugins.notification.local.schedule({ 
    id: 1, 
    title: "Message Title", 
    message: "Message Text", 
    firstAt: date, // firstAt and at properties must be an IETF-compliant RFC 2822 timestamp 
    every: "week", // this also could be minutes i.e. 25 (int) 
    sound: "file://sounds/reminder.mp3", 
    icon: "http://icons.com/?cal_id=1", 
    data: { meetingId:"123#fg8" } 
}); 

// firstAt and at properties must be an IETF-compliant RFC 2822 timestamp 

私はあなたがJSのDateオブジェクトを作成し、次に準拠したタイムスタンプを作るために.toUTCString()を実行することができると信じて。

関連する問題