In XCode 11, there is a new Background Mode, "Background Processing". I cannot find any information on what this new Background Mode does.
Are there any resources with that information?
In XCode 11, there is a new Background Mode, "Background Processing". I cannot find any information on what this new Background Mode does.
Are there any resources with that information?
I want to know if there is a way to run a process even when my app isn't running. Is that possible?
Here, a link that explain what it is and how to use it.
Say like you wanted to clean up your database in background to delete old records. First, you have to enable background processing in your Background Modes Capabilities. Then in your Info.plist add the background task scheduler identifier. Then in 'ApplicationDidFinishLaunchingWithOptions' method register your identifier with the task.
// Downcast the parameter to a processing task as this identifier is used for a processing request
self.handleDatabaseCleaning(task: task as! BGProcessingTask)
}
Do the work that you wanted to perform in the background and put it into the operation queue. In our case, the cleanup function will looks like:
func handleDatabaseCleaning(task: BGProcessingTask) {
let queue = OperationQueue()
queue.maxConcurrentOperationCount = 1
// Do work to setup the task
let context = PersistentContainer.shared.newBackgroundContext()
let predicate = NSPredicate(format: "timestamp < %@", NSDate(timeIntervalSinceNow: -24 * 60 * 60))
let cleanDatabaseOperation = DeleteFeedEntriesOperation(context: context, predicate: predicate)
task.expirationHandler = {
// After all operations are canceled, the completion block is called to complete the task
queue.cancelAllOperations()
}
cleanDatabaseOperation.completionBlock {
// Perform the task
}
// Add the task to the queue
queue.addOperation(cleanDatabaseOperation)
}
Now, when the app goes into the background we have to schedule the background task in BGTaskScheduler.
Could I get clipboard when webdriver is running in background, through the "Background Processing" ?