I need to be able to program background tasks. Little "crons" if you will, that execute some simple code. While not being an expert in GCD I was wondering:
What is the maximum time I expect for the background task to actually perform its duties in the background before apps quits completely
Can I "program" multiple tasks and expect them to complete in timely order
Are they only active as long as the app is launched? ( I bet they are, unlike local notifications that dont really care whether the app is running in the background or not, so just asking to be sure)
How to I keep track of them and cancel if needed?
For instance I able to do something like this and task is performed. I went as far as 1 minute here and it works.
let backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil) DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 60) { // Some action here UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier) })