【问题标题】:Ionic Local Notification Show All离子本地通知显示全部
【发布时间】:2018-02-19 14:36:56
【问题描述】:

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

我基本上从 ionic 文档中编写的代码,但是当我在我的真实设备上尝试它时,通知总是在设置最后一个 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'
}]);

对不起,我的英语非常糟糕,希望你能理解。

【问题讨论】:

    标签: ionic-framework notifications local


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 2021-03-20
      • 2023-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多