如何设置每 X 分钟本地通知一次?

How to set local notification every X minutes?

我正在尝试这样设置它们:

this.localNotifications.schedule({
              id: 0,
              text: 'Message',
              sound: this.platform.is('android') ? 'file://sound.mp3' : 'file://beep.caf',
              every: this.NotificationsTimer,
              icon: 'notification_icon',
              led: '#ff00c3'
            });

this.NotificationsTimer 的值为 5。但是它不起作用,我应该如何让它起作用?

您现在使用 Ionic 获得的版本似乎是 0.8.5。那么您应该将 every 与以下字符串之一一起使用:

  • 分钟
  • 小时
  • 一周
  • 季度

如果您使用的是最新版本(0.9.x,目前处于测试阶段),则有更多选项。以下信息取自 cordova-plugin-local-notifications 存储库:

重复,从现在开始:

trigger: { every: 'day', count: 5 }

或者每次日期匹配时:

trigger: { every: { month: 10, day: 27, hour: 9, minute: 0 } }