如何在离子的特定时间每天获得本地通知?

时间:2018-05-08 06:55:22

标签: ionic-framework ionic3

我希望每天上午10:00收到本地通知。 我的代码是:

var pushTime = moment().add(0, 'days').hours(10).minutes(0).seconds(0);

    cordova.plugins.notification.local.schedule({
        id: 1,
        text: 'Tracking Enabled ',
        trigger: { at: pushTime.toDate() },
        every: 'day'
    });

2 个答案:

答案 0 :(得分:0)

尝试使用触发器,如下所示:

trigger: {
   firstAt: pushTime.toDate(),
   every: ELocalNotificationTriggerUnit.DAY
}

答案 1 :(得分:0)

let notifications = []
let template = {
  data: "value",
  id: 1,
  title: "daily alarm",
  text: 'Code something epic today!',
  launch: true,
  foreground: true,
  trigger: { every: { hour: 10, minute: 0 } },
}
notifications.push(template)
cordova.plugins.notification.local.schedule(notifications);