Phonegap本地通知-每日



在https://github.com/katzer/cordova-plugin-local-notifications开发的phonegap插件中如果我想安排每日14:00的通知,该如何设置段落?我应该在日期上写什么?

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

谢谢锤

下面的示例展示了如何调度每天触发的本地通知,从现在起60秒。

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

你必须这样做

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

最新更新