I want to send notification at 8pm time on every day in ionic v1. I have referred following code but It gives the exception. Which datetime format should be used here. I never found complete code anywhere. Please help me out.
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)
From here:
Specifically:
I believe you can make a JS Date object and then run
.toUTCString()
to make a compliant timestamp.