Hi everyone! I started using Ionic with Capacitor a few weeks ago and have been thoroughly enjoying it.
The application that I’m building depends on the ability for users to schedule notifications - both one-off and recurring - and I seem to have the one-off notifications working, and I’ve had some successful recurring notifications trigger, but they haven’t all fired consistently and I’m having trouble debugging it because the documentation for the plugin is a bit limited in the details it provides.
I’ve looked through the source of the plugin as well and learned a few things from that, but it doesn’t quite answer every question. It seems like I would only be able to answer some of my questions by going deeper into the Android source itself instead of Capacitor and I would prefer that be a last resort.
If someone can help me figure out how each of the schedule options works and what the typical use case is for them, I’d be extremely grateful.
-
at
- I know this attribute is what should be set when scheduling a notification to fire one time, at a specific date and time (both date and time required for scheduling).-
repeats
- I don’t understand this attribute in relation toat
. Ifat
designates a specific date and time, how can the notification repeat at that date and time, since a date and time can only happen once?
-
-
every
- how does this attribute determine the start of the interval? does it start the interval as soon as you create the notification? so, like, if I setevery
tohour
, then the first time it will fire will be one hour from now, and then it’ll fire one hour after that, etc.?-
If that’s an accurate description of how it works, then is there a way to get more specific than just an individual instance of a provided unit? for example, instead of it being “every hour,” is there a way to make it “every two hours,” “every five hours,” etc.?
-
count
- I don’t really understand what this attribute is supposed to do in relation toevery
. If the configured schedule says, “trigger this notification every hour,” then what does settingcount
do? Because of the way the schedule is created, it’s already going to only fire once per hour. So limiting the number of times it can fire to any number above 1 doesn’t seem like it’ll have an effect because it’s already not going to fire more than once per hour; and setting it to 0 just means it won’t ever fire, right?
-
-
on
- I understand how this attribute works in general, but feel like I need some clarification of a few things. The description mentions that it’s similar to cron, but what are its differences from cron?-
If I create an
on
schedule and provide onlyhour: 3
in its attributes, does that mean this notification will fire at exactly 3am, every day, every month? -
What are the default values for any attributes left out? Does not providing an attribute mean that every instance of that unit will be taken into consideration when scheduling the notification? For example, if I leave out the
weekday
attribute, then the notification will fire every week day, Sunday through Saturday? If so, does this also apply to theminute
andhour
attributes? Meaning, if those two are left out and the attributeday: 10
is provided, then the notification will fire every minute and every hour (which overlap) on the 10th day of every month? -
And finally, is it possible to schedule a notification using a cron string that will be interpreted instead of an object?
-