I want to build a function where the current location of the user will be send to the server in every 5 minutes.Doesn’t really sound like something Apple is going to like.
This will be an in-house app though (and the users know their location are used), are rules less strict for this? Anyone any experience on this?
Thanks in advance!
Seems like a very straight forward case.
Enabled background location service requirement in your PLIST file, put a disclaimer in your app description stating continuous use of GPS in background will drastically drain battery, then have your code upload your GPS location every 5 minute.
It’ll work even in background 🙂
I have an app on the app store that records the user’s route live as the user drives around, though it doesn’t send to the server, it does track the user’s own location constantly and when the user is done, they can stop the GPS tracking.
Some Code Suggestions
Tracking user’s location isn’t a one line thing but I can suggest a learning route, which isn’t too overwhelming.
First of all, there are two parts to your problem:
a) Tracking user’s location
b) Sending the user’s GPS coordinate to the server
Tracking User’s Location
Tracking the user’s location can be done in two ways. You can either use CLLocationManager to track the user’s location or if you want the quick and dirty method, you can use the MKMapView’s delegate method:
PHP Server-side Code