问题
In the phonegap plugin developed by https://github.com/katzer/cordova-plugin-local-notifications if I want to schedule a daily notification at 14:00, how should set for the paras? What should I put for date?
window.plugin.notification.local.add({
id: String, // A unique id of the notifiction
date: Date, // This expects a date object
message: String, // The message that is displayed
title: String, // The title of the message
repeat: String, // Either 'secondly', 'minutely', 'hourly', 'daily', 'weekly', 'monthly' or 'yearly'
badge: Number, // Displays number badge to notification
sound: String, // A sound to be played
json: String, // Data to be passed through the notification
autoCancel: Boolean, // Setting this flag and the notification is automatically canceled when the user clicks it
ongoing: Boolean, // Prevent clearing of notification (Android only)
}, callback, scope);
Thanks Hammer
回答1:
The following example shows how to schedule a local notification which will be triggered every day, 60 seconds from now.
var d = new Date();
d.setHours(14);
window.plugin.notification.local.add({
id: 1,
title: 'Reminder',
message: 'Dont forget to buy some flowers.',
repeat: 'daily',
date: d
});
回答2:
You have to do like this
var d = new Date();
d.setHours(14);
d.setMinutes(0);
d.setSeconds(0);
window.plugin.notification.local.add({
id: "123", // A unique id of the notifiction
date: d, // This expects a date object
message: "you message", // The message that is displayed
title: "Your message", // The title of the message
repeat: 'daily', //this will repeat daily at 14:00 time
autoCancel: true,
}, callback, scope);
来源:https://stackoverflow.com/questions/24371391/phonegap-local-notification-daily