Steffaan / cordova-plugin-local-notifications

Cordova Local Notifications Plugin
Apache License 2.0
31 stars 38 forks source link

Repeat every minute after the notification set to the specified week days runs #23

Open erdemakca1 opened 5 years ago

erdemakca1 commented 5 years ago

Provide a general summary of the issue.

Your Environment

Expected Behavior

Notifications set to days of the week are working correctly

trigger: {every: {weekday: 3, hour: hour, minute: minutes}}

Actual Behavior

I would like to receive notifications every minute, both on certain days of the week and after the first working moment

Context

I'm creating a recurring new notification for every 1 minute at the time the notification for the day of the week is triggered, but it doesn't work when the application is completely closed.

window.cordova.plugins.notification.local.on('trigger', (notification, args) => {
        app.notificationEveryMinute();
});

notificationEveryMinute: function () {
        cordova.plugins.notification.local.schedule({
                channel:"test2",
                id: app.idDGenerator(),
                title: 'Test',
                text: 'TestText',
                group:'test2',
                sound: 'file://torpedo.mp3',
                trigger: {
                        every: 'minute'
                }
        });
}

In fact, the use will work with the second.

trigger: {every: {weekday: 3, hour: hour, minute: minutes, second: second}}

erdemakca1 commented 5 years ago

Ok. I its done. Make some changes in plugin files. TriggerReceiver.java, MatchTrigger.java and Request.java

I can give advices and files if anyone needs.

SimonBrazell commented 5 years ago

@erdemakca1 I'm having an issue with this too, doing this with Ionic 3:

let date = new Date(2019, 7, 11, 12, 30); // some date in the future. 
this.localNotifications.schedule({
                id: 1,
                title: 'title',
                text: 'text',
                trigger: {
                  every: {
                    weekday: date.getDay(),
                    hour: date.getHours(),
                    minute: date.getMinutes()
                  }
                },
                priority: 2,
              });

But I notice in the iOS logs when I do this that it says [local-notification] Next trigger at: (null) and the notification does not trigger at the time scheduled.

Can you share your fix for this?

SimonBrazell commented 5 years ago

@erdemakca1 actually never mind I found the issue, it appears that the plugin has Sunday as weekday 7, while for a JS Date object Sunday is weekday 0. This doesn't appear to be documented so I had to find it out with trial and error...

@Steffaan were you aware of this caveat?

erdemakca1 commented 5 years ago

Yes @SimonBrazell Sunday is 7.