I tried
LSSharedFileListRef globalLoginItems = LSSharedFileListCreate(NULL, kLSSharedFileListGlobalLoginItems, NULL);
if (globalLoginItems) {
LSSharedFileListItemRef ourLoginItem = LSSharedFileListInsertItemURL(globalLoginItems,
kLSSharedFileListItemLast,
NULL, NULL,
(CFURLRef)[[NSBundle mainBundle] bundleURL],
NULL, NULL);
if (ourLoginItem) {
CFRelease(ourLoginItem);
} else {
NSLog(@"Could not insert ourselves as a global login item");
}
CFRelease(globalLoginItems);
} else {
NSLog(@"Could not get the global login items");
}
LSSharedFileListInsertItemURL() just returned NULL when I built and ran the application. Is there something else that I need to do? Some kind of authorization?
NOTE: The use-case here is for global login items, that is using kLSSharedFileListGlobalLoginItems and not kLSSharedFileListSessionLoginItems.