Update your app via API
Setapp updates apps in the background and never interrupts a running app to do so. This works well for most apps, but apps that stay open all the time, such as menu bar tools and background utilities, can remain on an old version for weeks simply because there is never a moment to quit them.
The app update API solves this. It adds two functions to SetappManager: one lets your app ask Setapp whether a newer version is ready, and the other tells Setapp to install it. This means your app can decide when to update — after the user agrees, on quit, or when the app is idle — instead of waiting for Setapp to find a free moment on its own.
Setapp knows which app version is running because the request includes that information.
Check for a pending update
To learn whether Setapp has a newer version of your app, call the requestPendingUpdate(completionHandler:) function of the shared SetappManager. The completion handler receives a SetappPendingUpdate value when an update is available, or nil when the running copy is up to date.
SetappManager.shared.requestPendingUpdate { result in
switch result {
case .success(let update):
if let update {
// A newer build is ready to install:
// update.version, update.buildNumber,
// and update.releaseNotes with the release notes in Markdown, if any.
} else {
// The app is up to date.
}
case .failure(let error):
// The check failed, for example, Setapp is not running.
}
}The check reads the app's local update state, which Setapp already keeps up to date in the background. It doesn't create any network traffic itself, so it's safe to call regularly — on launch, once a day, or right before showing your update UI.
Use releaseNotes to tell the user what the new version brings. The property contains the release notes of the pending version as Markdown source, and it can be nil when the version has no notes.
Apply the pending update
To install the pending update, call the applyPendingUpdate(completionHandler:) function of the shared SetappManager. Setapp downloads the new version, quits your app, installs the update, and relaunches the app.
Because your app is quit during the update, make sure it has saved all user data before the call, and consider asking the user for confirmation first.
Only offer the update after requestPendingUpdate(completionHandler:) has reported a pending version, and include that version in your message — for example, "Update to 2.5.0? The app will quit and relaunch." Checking first means you never ask the user to quit the app just to find out there was nothing to install.
SetappManager.shared.applyPendingUpdate { result in
if case .failure(let error) = result {
// The update was not applied, and the app keeps running.
}
// On success, Setapp quits, updates, and relaunches the app,
// so the completion handler never reports a success.
}A few things to keep in mind:
- The completion handler only reports failures. On success, your app quits to install the update — before it can receive any reply.
- Calling
applyPendingUpdate(completionHandler:)without a pending update returns an error. Check for a pending update first withrequestPendingUpdate(completionHandler:). - If the installation fails after your app has quit, Setapp relaunches the previous version — your app is never left closed.
- If the call fails with a connection error, the update may still be running in the background. Call
requestPendingUpdate(completionHandler:)again to check the actual state, rather than immediately retrying the update.
- Setapp Framework 5.5.0 or newer in your app
- The Setapp desktop app version 3.56.0 or newer on the user's Mac. With an older Setapp version, both calls complete with an error.
Updated about 2 hours ago
