... well maybe not so much profit.
CoreLocation is really cool. Nice easy way to get a reasonably accurate geolocation of iOS and OS X devices. I'm going to focus on OS X here.
CoreLocation can be a pain. It now insists that apps that request location data be signed and authorised by the user.
So the authorisation file for apps it turns out is located at /var/db/locationd/ on 10.9 machines and it's located in the clients.plist file. Aha! We can use defaults write for this. Ack! It's a bunch of arrays. Not nice.
Step One: Find the app you wish to sneakily authorise. You'll need to authorise it manually on a computer and grab the results. I'm using an app i've found called "whereami". You'll end up (after running defaults read on this file) with something like ...
"com.apple.locationd.executable-/Volumes/xxx/whereami" = (
{
Authorized = 1;
BundleId = "com.apple.locationd.executable-/Volumes/xxx/whereami";
Executable = "/Volumes/xxx/whereami";
Hide = 0;
Registered = "/Volumes/xxx/whereami";
Whitelisted = 0;
}
);
Step Two: Translate what you've got into something you can put into a defaults write command. For the record, dealing with arrays with defaults is a pain. I eventually ended up with this:
defaults write /var/db/locationd/clients.plist com.apple.locationd.executable-/Volumes/xxx/whereami -array-add '{"Authorized" = "1"; "BundleId" = "com.apple.locationd.executable-/Volumes/xxx/whereami"; "Executable" = "/Volumes/xxx/whereami"; "Hide" = "0"; "Registered" = "/Volumes/xxx/whereami"; "Whitelisted" = "0";}'
Step Three: There is no step three!
You've basically authorised an app for CoreLocation without bugging the user to authorise it. I've specifically done this for some missing computer tracking stuff i'm working on. Saying that, if there's an easier way of doing this then i'd love to hear it!
