Im simply scheduling a notification. I use moment js to start the scheduling tomorrow at an hour specified by the user.
So i just simply: let date = moment(date).add(1, 'days').toDate() do this to get the next day.
Then i just
`
//We set the new date to the next notifications
let notification = {
title: "Welcome",
text: "Lets start with your first reflection",
at: new Date(),
every: '"day"
};
notification.at = date;
this.localNotifications.schedule(notification);
`
To be sure I print the notification.at, and I've got the tomorrow at some hour correctly. But the device don't care about the at. It just takes the hour. Example, if I right now are the 20:00, and I scheduled something for tomorrow at 20:02, the notification is fired in two minutes.
Lets suppose it's 22:00pm, and I schedule an hour introduced by the user (that hour will be 22:05pm) and do the next thing. let date = moment(date).add(1, 'days').toDate();
So the first notification must be triggered everyday starting tomorrow at 22:05.
Lets suppose it's 22:00pm, and I schedule an hour introduced by the user (that hour will be 22:05pm) and do the next thing. let date = moment(date).add(1, 'days').toDate();
So the first notification must be triggered everyday starting tomorrow at 22:05, but instead, the first notification it's triggered today at 22:05pm
I'm trying to schedule repeating notifications everyday, starting from tomorrow.
_Include iOS / Android logs_
You're firing the notification every day. I think you need to look at the startAt concept.
@JoshuaPerk I've tried with firstAt and it was the same. Also I read here https://github.com/katzer/cordova-plugin-local-notifications/issues/1412 that firstAt does not work and will not work on iOS
With iOS 10+ there's no support for firstAt property anymore, but instead there are other options with v0.9
@katzer So if I understand you correct with the firstAt value not supported on iOS. It is not possible to make a notification that is repeated every friday at for example 16:00, both on Android and iOS?
{ trigger: { every: { weekday: 5, hour: 16, minute: 0 } } }
Nice! Thank you @katzer ! 馃槃
@katzer Just one question! Is weekday not supported in the current version 0.8.5? Seems that the hour and minute values works great, but not with the weekday value.
The whole syntax and feature-set (not just weekday) requires v0.9
With v0.8 you would need to calculate the first date and specify a weekly interval.
Ok, but is the v0.9 available at any branches? My config.xml file includes this plugin line:
plugin name="cordova-plugin-local-notification" spec="git+https://github.com/katzer/cordova-plugin-local-notifications.git
But should i add a specific branch for the syntax to be working?
... is the v0.9 available at any branches?
master branch
Ah ok, my bad. So the plugin line in the config.xml is know looking like this:
plugin name="cordova-plugin-local-notification" spec="^0.9.0-beta.1"
Is that correct?
Should the cordova version be 7.1.0 or 8.0.0 ?
with 8.0.0 I had to remove an .xml file manually. Other then it works with both 7.1 and 8.0
Nice, I am using the version 7.1.0 so i think i would use that one for now. Here is my function for the notification that is been added to a array of notifications to be scheduled:
let notification = {
id: 1,
title: 'Example title',
text: 'Example text',
trigger: { every: { weekday: 3, hour: 8, minute: 59 } },
foreground: true,
actions: [
{ id: 'yes', title: 'Yes' },
{ id: 'no', title: 'No' }
]
}
The trigger is set to current time for testing out that it works. The notification works when I don't use the weekday value, but maybe i don't have the syntax right?
support for weekday for Android+Windows has been added after the release of 0.9.beta.1
Ok, I am testing this on iOS in the emulator on macOS. And it still dont work. Another value like weekOfMonth work fine.
Has been fixed!