phonegap本地通知 - 每日

时间:2014-06-23 17:00:29

标签: cordova phonegap-plugins

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

由于 锤

2 个答案:

答案 0 :(得分:2)

以下示例显示如何安排将在每天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
});

答案 1 :(得分:1)

你必须这样做

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