安排本地通知ionic 4

时间:2019-05-30 15:56:46

标签: angular ionic-framework angular7 ionic4

我正在获取用户的时间输入,并且我想在该时间安排每天的本地通知。问题是这不起作用:

this.localNotifications.schedule({
   text: 'Delayed ILocalNotification',
   trigger: {at: new Date(new Date().getTime() + 3600)},
   led: 'FF0000',
   sound: null
});

我必须像这样使用它。这将在5秒钟内触发通知:

this.localNotifications.schedule({
   text: 'Delayed ILocalNotification',
     trigger: {
     in:5,
     unit:ELocalNotificationTriggerUnit.SECOND
   }
  });

1 个答案:

答案 0 :(得分:0)

由于Ionic的本地通知插件是此cordova插件的包装,因此: https://github.com/katzer/cordova-plugin-local-notifications

您是否尝试过应用以下方法:https://github.com/katzer/cordova-plugin-local-notifications#repeating

类似这样的东西:

this.localNotifications.schedule({
   title: 'Happy Birthday!!!',
   trigger: { every: { month: 10, day: 27, hour: 9, minute: 0 } },
   text: 'Delayed ILocalNotification',
   led: 'FF0000',
   sound: null
});