Frequently Asked Questions
Q. How often will my jobs run?
A. On iOS, it depends. iOS schedules jobs to run when the user generally is about to use your app. It is a pre-emptive task. On Android, roughly every 15mins unless Doze is enabled. Doze will look at things like battery and time of day similar to how iOS does things.
Q. My iOS job isn't repeating
A. If it ran once and you've set repeat to true on the JobInfo, it will run, but again - iOS needs a few days to learn how the user uses your app. If you need more control on when things run, jobs is not the answer. You should consider looking at push notifications
Q. How long does the background sync let me have on iOS
30 seconds and not a penny more
Q. How do I schedule periodic jobs?
All jobs are considered periodic with or without criteria
Q. How many jobs can I run?
A. Technically as many as you want... BUT this was built with mobile timeslicing in mind (ie. iOS). Your job set needs to complete within that timeslice as we don't set job ordering currently
Q. Why can't I set the next runtime
A. From a true runtime perspective you can't, however, inside you job you can set add/update the job parameters or check the last runtime on the job info to see if you want to run. Example below:
public class SampleJob : IJob
{
public async Task Run(JobInfo jobInfo, CancellationToken cancelToken)
{
var runJob = false;
if (jobInfo.LastRunutc == null) // job has never run
runJob = true;
else if (DateTime.UtcNow > jobInfo.LastRunUtc.AddHours(1))
runJob = true; // its been at least an hour since the last run
if (runJob)
{
... do your job
}
}
}