Hello,
I have many apps that use LoginItem logic to enable the auto start.
I always used the function SMLoginItemSetEnabled
to enable or disable the launch of the LoginItem.
I am using macOS Ventura Beta for quite some time now and I noticed that whenever I launch one of my apps, a message appears. It says that my app added some functions. When I click on the message, the Login Items section of the System Preferences opens and my recently opened app is listed under "Allow in the Background".
I want to port my apps to the new logic but I am not quite sure how to do that. I don't want my apps to appear under the "Allow in the Background" section but rather in the "Open at Login" section.
I am using the following code to enable or disable the auto start under macOS 13.0+:
if autoLogin
{
try? SMAppService.mainApp.unregister()
}
else
{
try? SMAppService.mainApp.register()
}
This works very well. If I check my switch, the app appears under the "Open at Login" section. If I disable the switch, the app disappears from this list. Great, this is what I want. However...when I restart my Mac, the app is launched automatically. And now there is a new entry in the "Allow in the Background" section again.
What am I doing wrong? Should I register or unregister the LoginItem instead? This is not really what I want, it appears in the wrong section and I think this is confusing for users.
I read somewhere else that the user consent is stored, even when resetting with sfltool or something like that. Does the item appear in this section (and is launched automatically) because I launched the app earlier without my new logic?
Is this simply a bug?
has anyone a working example of how to properly support auto launching an application under macOS Ventura and earlier versions?
Regards, Sascha