离子本地通知全部显示

时间:2018-02-19 14:36:57

标签: ionic-framework notifications local

我想每天两次向我的应用用户推送一些通知。

我基本上从离子文档编写的代码,但是当我在我的真实设备上尝试时,通知始终显示在设置最后一个id的时间。

这是我的代码:

this.localNotifications.schedule([{
   id: 1,
   text: 'Time to get your morning rewards!',
   at: new Date(new Date().setHours(7)),
   every:'day'
  },{
   id: 2,
   text: 'Time to get your morning rewards!',
   at:new Date(new Date().setHours(16)),
   every:'day'
}]);

对不起我非常糟糕的英语,我希望你明白。

1 个答案:

答案 0 :(得分:0)

我认为你遇到了时区问题。试试这个:

let date1 = new Date();
date1.setHours(7);
date1.setMinutes(0);
date1.setSeconds(0);

let date2 = new Date();
date2.setHours(16);
date2.setMinutes(0);
date2.setSeconds(0);

this.localNotifications.schedule([{
   id: 1,
   text: 'Time to get your morning rewards!',
   at: date1,
   every:'day'
  },{
   id: 2,
   text: 'Time to get your morning rewards!',
   at:date2,
   every:'day'
}]);
相关问题