How to get local notification everyday at specific time in ionic?

廉价感情. 提交于 2019-12-13 03:39:56

问题


I want to get local notification everyday at 10:00 AM . my code is:

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

回答1:


Try to use trigger as below:

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



回答2:


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


来源:https://stackoverflow.com/questions/50227613/how-to-get-local-notification-everyday-at-specific-time-in-ionic

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!