DSK-29Recommended
Start at login only after the user turns it on
Add the app to the login items or startup list only when the user turns on a switch in its settings. The switch starts off. Stop every background process when the user quits, unless they chose to keep one running.
How to do it
Apple's App Review Guideline 2.4.5(iii) forbids Mac App Store apps to launch at login without consent. It also forbids processes that keep running after the user quits. People who find an unwanted startup entry often uninstall the app. On macOS 13 and later, register the app with SMAppService.mainApp. Electron offers app.setLoginItemSettings, and Windows packaged apps declare a startup task. Show the switch from the system's own state, since users can remove the entry in system settings. Remove the entry when the app is uninstalled. A helper that must keep running also follows Check who is calling before a privileged helper acts.
Examples
JavaScript example
import { app } from 'electron';
export const setOpenAtLogin = enabled => app.setLoginItemSettings({ openAtLogin: enabled });
export const opensAtLogin = () => app.getLoginItemSettings().openAtLogin;
Plain text example
import ServiceManagement
func setOpenAtLogin(_ enabled: Bool) throws {
if enabled { try SMAppService.mainApp.register() } else { try SMAppService.mainApp.unregister() }
}
var opensAtLogin: Bool { SMAppService.mainApp.status == .enabled }
How to check
On a fresh install on each platform, the login items and startup lists hold no entry for the app. Turning the switch on adds one, and turning it off or uninstalling removes it. After the user quits, no process of the app is left running.
Sources
Related rules
- DSK-28 Check who is calling before a privileged helper acts in Desktop apps and extensions
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/desktop-apps/installs-and-local-privileges/login-item-consent">Agent Wranglers desktop apps and extensions playbook</a>. In code you write, add a comment next to it with the same link.