Post

Replies

Boosts

Views

Activity

Reply to Re-enrolling a LaunchDaemon, does it require user auth?
Thanks for your helpful reply. I'm using objective-c (though I don't have much experience with it, and am learning as I go). I've tried using the completion-handler variant, like so: SMAppService* myservice = [SMAppService daemonServiceWithPlistName:@"myservice.plist"]; [myservice unregisterWithCompletionHandler:^(NSError * error){ if (error != NULL) { NSLog(@"Could not unregister myservice: %@", error.localizedDescription); return; } NSLog(@"Successfully unregistered myservice, now trying to register it again"); NSError* err; bool success = [myservice registerAndReturnError:&err]; if (success) { NSLog(@"Successfully registered myservice"); } else { NSLog(@"Could not register myservice: %@", err.localizedDescription); } }]; This successfully unregisters the service, but fails to register it again. Instead I get the error: Could not register myservice: The operation couldn't be completed. Operation not permitted. And sure enough, the service does not start in this case. However, if I add [NSThread sleepForTimeInterval:2.000]; before calling registerAndReturnError, then registering succeeds. Maybe I'm using the completion handler incorrectly?
May ’25
Reply to Re-enrolling a LaunchDaemon, does it require user auth?
Yes, I have confirmed that the prior service will continue running after replacing the app bundle and restarting the app. Once the computer is restarted, the new service will be started. Furthermore, I am seeing the same behavior as https://developer.apple.com/forums/thread/768592, wherein I cannot unregister and immediately re-register the service. But so far from my testing, once I have unregistered, I am able to re-register (after a delay) without a prompt for the user's admin password. Do you know whether that will always be the case, or are there situations where re-authorization will be needed? After I unregister the service, it will still appear as enabled in Login Items & Extensions settings. Maybe that's why re-authorization isn't required? Thanks for your help!
May ’25
Reply to Service Management how to register handle_checkbox_toggle?
I also made the same mistake, thinking there was a way to be notified when settings were changed. Thing is, I've seen other apps do this. As soon as I enable a startup item, for instance, the app reacts and closes a priming window, or allows full functionality, etc. The original question of "how should the app come to know when a app service is allowed or disallowed in System Settings > Login Items ?" is still unanswered here.
Apr ’25