Schedules | iOS interpreting schedules as an ongoing or "active"

Hi!

Thank you to Kmart who gave me the answer on my question regarding issue when eventDidReachThreshold triggers immediately! But, I still have a few questions, so I’m posting the new post.

Could you please give answers for the next questions:

  1. How I can avoid the behaviour when system could interpreting schedules as an ongoing or "active"? I noticed that when I manually change the Date for the next day, eventDidReachThreshold doesn’t invoke.
  2. Are schedules incapsulate accumulated threshold time or the threshold time is shared between schedules?
  3. Why eventDidReachThreshold invokes even in case for the past day I didn’t open apps to accumulate threshold time? When I check spent time in iPhone settings, the Screen Time show that I spent 0 minutes for the apps which were selected for accumulating threshold time.
  4. Is it correct that the last schedule that was starting has more priority than the previous one?
  5. Can we manually set priority for starting schedules?
  1. In order to exclude device usage from the beginning of the day, use the hour/minute/second components of Date.now as the start components of your schedule. If you are trying start a repeating schedule from 12:00am to 11:59pm, you might need to use two different schedules: a non-repeating schedule for the first "partial" day and then when you get the intervalDidEnd callback for that first "partial" day, you can then start monitoring your actual repeating schedule for 12:00am to 11:59pm.
  2. I'm not sure I understand the question, but each schedule and event are treated independently by the system. In other words, the fact that you are monitoring schedule A and schedule B at the same time will not cause them to interfere. The callbacks you get for schedule A will occur just the same as if you were monitoring just schedule A and not schedule B.
  3. That sounds like a bug with either the schedule or the event you are creating.
  4. I don't understand what you mean by priority. Each schedule will cause your extension to get callbacks whenever its interval starts and ends. Similarly, each schedule's events will cause your extension to get callbacks whenever their threshold is reached.
  5. No. The system does not prioritize schedules differently.

Kmart, I highly appreciate your quick response and provided answers for each of my questions!

I'm clear with 2nd, 3rd, 4th and 5th. Let me clarify the 1st one please:

In order to exclude device usage from the beginning of the day, use the hour/minute/second components of Date.now as the start components of your schedule. If you are trying start a repeating schedule from 12:00am to 11:59pm, you might need to use two different schedules: a non-repeating schedule for the first "partial" day and then when you get the intervalDidEnd callback for that first "partial" day, you can then start monitoring your actual repeating schedule for 12:00am to 11:59pm.

For creating schedules from the beginning of the day I do so:

let mondaySchedule = DeviceActivitySchedule(
    intervalStart: DateComponents(hour: 0, minute: 0),
    intervalEnd: DateComponents(hour: 23, minute: 59),
    repeats: true
)

I'm trying to reach a vice versa implementation:

I'd like to create a repeatable schedule, let say for each Monday, and this schedule has to invoke eventDidReachThreshold. On top of it, I'd like to create another one "partial" repeatable schedule, let say on Monday from 2pm to 4pm, this schedule hasn't invoke eventDidReachThreshold.

So, my question is: Is eventDidReachThreshold has to work properly, in case it was programmed for the whole repeatable day schedule?

And what if I'd like to create the same schedules for Tuesday (both, for whole day and "partial" and both are repeatable), will it have negative impact on Monday's schedules and for the eventDidReachThreshold event?

Schedules | iOS interpreting schedules as an ongoing or "active"
 
 
Q