I am trying to write a small app that would run a job at set intervals, just like a cron job. To achieve this, I have used the period method just like in the documentation, the following way:
However, this causes the job to run every time the app opens. I would only like to run on the predefined schedule.
I have also tried with setting executor: .background. With this method, the job never runs. This is because the RepeatConstraint always returns false on the run method when the executor is background. Because of this, the job can never be triggered and the schedule only starts after one successful completion (which can never be triggered).
Moreover, the Executor enum's documentation suggests that the job will run only when the app is in background/foreground (for example by observing UIApplication.shared.applicationState), which it does not.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am trying to write a small app that would run a job at set intervals, just like a cron job. To achieve this, I have used the period method just like in the documentation, the following way:
However, this causes the job to run every time the app opens. I would only like to run on the predefined schedule.
I have also tried with setting
executor: .background
. With this method, the job never runs. This is because the RepeatConstraint always returns false on therun
method when the executor is background. Because of this, the job can never be triggered and the schedule only starts after one successful completion (which can never be triggered).Moreover, the Executor enum's documentation suggests that the job will run only when the app is in background/foreground (for example by observing
UIApplication.shared.applicationState
), which it does not.