Search code examples
typescriptionic-frameworkionic2ionic-native

How to set local notification every X minutes?


I am trying to set them like this:

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 has a value of 5. But it doesn't work, how should I make this work?


Solution

  • It seems like the version you get with Ionic right now is 0.8.5. Then you should use every with one of the following strings:

    • second
    • minute
    • hour
    • day
    • week
    • month
    • quarter

    If you are using the latest version (0.9.x, currently in beta), there are more options. The following info is taken from the cordova-plugin-local-notifications repo:

    Repeat, relative from now:

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

    Or every time the date matches:

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