tags:

views:

86

answers:

2

For the sake of this question, assume I plan to build a Google Latitude client app for iOS 4. my app needs to upload the user gps location every two minutes, and also download the user friends locations. - in the background!

my app can't wait to be woken up by the OS on cellular tower switches (because they may only happen after 2 KM, while my app needs constant gps updating), so I understand I can create a thread, similar to the ones GPS navigators use, to run in the background.

I have no knowledge in iPhone programming, I just need to know if my app is feasible.

  1. Will I be able to access the internet from within the background thread (and upload the user gps location), or is it restricted to only sampling the GPS location. 1.
  2. Will Apple approve such an application, or is this type of use forbidden? because my app isn't realy critical such as a gps navigator

Thanks!

A: 

You will receive the locationManager:didUpdateToLocation:fromLocation: message in your app. In there, you can do whatever you need to, although you should not update the UI or use Open GL if your are in the background.

Don
+1  A: 

As Don said, iOS will send location events to apps that support it. From there, the app can do what it needs to do with the location event.

Background apps can register for one of three options:

  1. Significant changes only: a low-power way to track location that only wakes the app up when there's a "significant" change in location
  2. Standard location services: compatible with all iOS devices that can use location services, allows you specify change in distance, and works in background. However, if the app has been terminated or suspended, iOS won't attempt to relaunch the app.
  3. Continuous location services: allows the program to receive continuous location updates and iOS will not suspend the application when sent to the background.

More info: Executing Code in the Background and Location Awareness Programming Guide

If you take a look at Executing Code in the Background, Apple provides guidelines on what multitasking-aware apps should and shouldn't do.

Mark Trapp
If I choose the continueous location services, in what intervals will I be updated? can I register an update for 100 meter change, or, every 2 minutes?how does it work?
eyalw
You specify a distanceFilter in meters. If the phone's moved more than distanceFilter, the app will be sent an event. If you specify kCLDistanceFilterNone as the distanceFilter, you get notified for all movements.
Mark Trapp