I am building an app that uses the SMAppService
to register a LaunchDaemon that is bundled with my .app
. I've got a priming flow created which walks the user through approving the service so that it will start on login.
However, I need to also be able to upgrade this background service if the user updates the app. To do this, I think I need to call unregisterAndReturnError
and then registerAndReturnError
.
From my testing, this seems to work correctly, but I have a concern. Will the user ever be prompted to re-authorize the LaunchDaemon that I am registering? If so, under what circumstances will that happen, and what does it look like (so that I can guide the user through it)?
IMO this is a bug. The doc comment I quoted above makes it clear that this is an expected use case.
I encourage you to file a bug about this. Please post your bug number, just for the record.
On the workaround front, you might wanna try this:
[myservice unregisterWithCompletionHandler:^(NSError * error){
dispatch_async(dispatch_get_main_queue(), ^{
… your re-registration code …
});
}];
because a simple turn of the run loop might be sufficient to get things working. If not, you’ll have to pick an arbitrary delay, which is not ideal but it’s not too bad either.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"