AGSGenerateOfflineMapJob while app is suspended?

655
2
Jump to solution
07-20-2019 04:12 PM
WorthSparks
New Contributor III

If I want to download a song, podcast, or similar content, I would use a URLSession, which allows a download to continue to completion, even if the app has been suspended or terminated. Once started, does AGSGenerateOfflineMapJob (or AGSExportTileCacheJob or AGSExportVectorTilesJob) continue running in the background, even if the app has been suspended or terminated?

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Yes. The job is really independent of the Runtime and will run on the server regardless of the client app state. Runtime connects to the job when it can and updates itself on the job's status, downloading the result of the job if appropriate.

Check out the JobManager class provided in the iOS Runtime SDK's Toolkit which helps manage jobs when your app is backgrounded and foregrounded. You register a job with the job manager, and then call this method when your app is returned to the foreground to reconnect to any jobs.

View solution in original post

2 Replies
Nicholas-Furness
Esri Regular Contributor

Yes. The job is really independent of the Runtime and will run on the server regardless of the client app state. Runtime connects to the job when it can and updates itself on the job's status, downloading the result of the job if appropriate.

Check out the JobManager class provided in the iOS Runtime SDK's Toolkit which helps manage jobs when your app is backgrounded and foregrounded. You register a job with the job manager, and then call this method when your app is returned to the foreground to reconnect to any jobs.

Nicholas-Furness
Esri Regular Contributor

Having spoken with our Apps team, I have a little more insight to share.

You should consider registering a Background Task with iOS when you kick off the job. Essentially this tells iOS that if your app is backgrounded while the job is running, you'd like to be able to check in on the job. This also gives the job the opportunity to start a download when the remote work is finished and a download package is available.

Next, Runtime will automatically make use of URLSession behind the scenes to handle the download of the job result as a Background Download. This allows iOS to manage the download process and ensure your file makes it to the device even if your app is backgrounded.

Note that Background Task, Background Download, and Background Fetch are 3 different things.

The JobManager integrates with Background Fetch by implementing a handler for application(_:performFetchWithCompletionHandler:). However, since iOS will modify how often that is called based off the return value (.newData or .noData), this could become non-deterministic.

I haven't fully experimented with all this myself yet.