How to create mac application, which will be always running in the background and collects Location?

2.1k Views Asked by At

I need to know how to create an application which will always be running in the background and collects location info once every 10 minutes. I don't know much about launch agents and daemons.

I have read a few examples where I found Launch agents is just a plist file. Should we launch the app through launch agents every 10 minutes? How to do that?

1

There are 1 best solutions below

2
James Bucanek On

There's no simple answer to this; you really need to read—or at least familiarize yourself with—the Daemons and Services Programming Guide, particularly the "Creating Login Items" section.

If you plan on creating a sandboxed (App Store) application, that limits your options somewhat, but not dramatically (for this kind of application).

You need to decide if your background process needs a UI or not. I suspect not, so I'd direct you to the either the XPC Service or user agent route. These will be registered with launchd and launchd has about a billion different options for how and when your process gets launched, and one of those is periodically. For more info on those, see man launchd.plist, particularly StartInterval and StartCalendarInterval.

With this knowledge, I'd then suggest to do some internet and open source searches looking for examples. I'm sure you'll find plenty.