Hi, I have been using the BackgroundTasks API on iOS for a while, and it works great. I want to do something similar on macOS, where I can easily run some background process from my app every X minutes, even if the app is closed. My Mac app runs in the sandbox, and isn't Catalyst-based, so I can't run the UIKit 'BackgroundTasks' API, and I haven't found anything similar on macOS. Does something like that exist, that is easy to adopt?
Background Tasks for macOS
There are several kinds of "daemons" and "agents" that can run in the background on macOS. Here's some documentation: Daemons and Services Programming Guide
As JWWalker mentioned, macOS uses a completely different background execution model than iOS, one based on separate processes. For a sandboxed app your best option is to use a Service Management login item, installed via SMAppService
API (or SMLoginItemSetEnabled
on older systems).
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"