【问题标题】:phonegap local notification - dailyphonegap 本地通知 - 每天
【发布时间】:2014-06-23 17:00:28
【问题描述】:

https://github.com/katzer/cordova-plugin-local-notifications开发的phonegap插件中 如果我想安排每天14:00通知,paras应该如何设置?我应该为约会写什么?

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

谢谢 锤子

【问题讨论】:

    标签: cordova phonegap-plugins


    【解决方案1】:

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

    【讨论】:

    • @TheBlackBenzKid 我更喜欢将其作为新问题发布。无论如何,如果您引用Wiki,请使用Cancel API 以及cordova.plugins.notification.local.cancel(1, function () { // Notification was cancelled }, scope); 中的通知ID
    【解决方案2】:

    你必须这样做

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

    【讨论】:

      猜你喜欢
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-04
      相关资源
      最近更新 更多