Stopping background location applications on iOS 4

As you may already know, iOS4 gives iPhones and iPads the ability to run applications in the background. Most people are also aware of the ‘task manager’ that you can activate by double-tapping the Home button. But how do you stop an application from running in the background?

Delete it. Seriously, that’s the only way (for location applications using the Significant Location Update service).

The ‘task manager’ is not actually managing anything, and the icons in there are not tasks. If you hold down the icons until they start to wobble and then tap the red X, you have terminated that application.

But location apps using the Significant Location Update service get restarted when:

  • the phone reboots
  • you change cell towers

So even though you’ve just turned it off, as soon as you get in your car and drive a mile, it comes back to life.

There are typically 3 reasons why you’d want to stop a location based application running:

  1. To stop it sending your location temporarily or permanently
  2. To test whether that has an impact on battery life
  3. To make the location arrow go away (this won’t work on iOS 4.1, see my prior post)

For case 1 and 3, you should really do what Apple recommend, and that is use the Settings application. Go to Settings->General->Location Services, and turn off either the specific application or all of them. The application will then be unable to get any location information from the CoreLocation API. This also has the effect of turning off the location arrow.

For case 2 your best bet is to delete the application. Turning off location access will remove an application’s ability to turn on the GPS chip, but that is only one of the ways to drain your battery. Continually sending data over the network via Edge or 3G is almost as bad, and the only way to stop that is to delete the app.

Advertisements

6 Responses to Stopping background location applications on iOS 4

  1. Johnmartyn says:

    What about double clicking the home button to get the app switcher, holding an icon until they wobble and tapping the red kill icon on the top right of the app you want to kill? Works for me…

    • Mick says:

      Hi John,

      That does indeed terminate the application. But if it’s using the Significant Location Update service, then when you change cell towers or reboot the phone, the application will be launched again into the background.

      Cheers,
      Mick

      • Mick,

        I don’t think this is accurate. Apps are never launch automatically! The background services are designed to allow in-background apps to temporarily come back to life (not necessarily in foreground) to respond to certain events.
        Also, in “background” all the app uses is memory – they are effectively frozen – and when terminated (either by the user or by the OS when memory needs to be reused) there is no way for the app to know that.

  2. Mick says:

    Hi Paul,

    I’m not sure what data you’re basing your statements on, but I can verify that applications do launch automatically.

    If you read the documentation on CLLocationManager, it says “If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives”

    Another way for you to test my assertion would be to download Whereoscope, remove it from the background, and then drive 2 miles.

    You will see the app pop up in the ‘task list’ again. Logging in on the Whereoscope website will also show you that the application has posted new location data, and must therefore have had access to both the GPS and the network.

    I actually wrote this article precisely because many of our users have the (incorrect) belief that you do.

    Cheers,
    Mick

  3. Pavlo says:

    Mick,

    Have you tried to call stopMonitoringSignificantLocationChanges in applicationWillTerminate? That might help I guess since it explicitly states you want it to stop updating location on app exit. Just an idea…

    • Mick says:

      Hi Pavlo,

      Thanks for commenting!

      I’m not sure precisely what you meant, but Whereoscope is designed to run all the time. So the vast majority of our users don’t want it to stop updating location on app exit.

      For example, we often have families using Whereoscope travelling by plane – and it works much better for the family to see when they land without the passenger having to explicitly start the Whereoscope app again.

      I initially wrote this post to help explain to the very small group of users that complained Whereoscope kept running after they removed it from the task manager.

      For the overwhelming majority of parents and kids using our service, making the default to ‘always just work’ has been the most popular.

      Cheers,
      Mick

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: