Question

I'm trying to come up with the best possible approach for the location tracking iPhone application which tracks location in the background.

Background model is slightly different from the Android and Windows Phone platforms and I'm not sure how to achieve the best possible result.

What I'm trying to accomplish is to:

  • periodically run a job in background even if my app is terminated
  • during background job fetch current user location during background
  • job submit the location to my server using POST Http Request

Most of background approaches are not working for me because they requires the app not to be terminated. I want to submit location even if the app is terminated. I also don't care how often my background job will be executed by the system, once a minute, once an hour or once a day. I need it as often as system allows me. I found the two possible solution:

  1. Background Fetch
  2. Remote Notification

The question is: Could I

  • fetch the user location when iOS gives me an opportunity to perform my background job (I believe, yes, with "Location Updates" mode enabled, but I'm not sure)?
  • submit a location to a backend server (not fetch but submit, using POST http method)?

Please, advise. Alternative solutions are appreciated.

Was it helpful?

Solution

the best way is to use apple's core location api

it provides many ways to track the users location based on accuracy required or battery life considerations

you can register with the notification center about location information.... the phone will periodically launch your app under special conditions (it won't launch the full thing) so that you can update your data and app variables accordingly

this way it won't matter if the app is open or not

the two things you need to look into are notification center and the core location api

here is a link to the api reference Core Location Framework Reference

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top