0

Is there a way to modify Background Mode for Location update programmatically in iOS 7?

The reason is that I want the user to decide if he wants to run the location manager in background.

At the moment I activated the location background mode, but I always have this arrow on the top of the display. Even if I call stopUpdatingLocation, I dont get rid of the "gps arrow".

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140

1 Answers1

0

If you call stopUpdatingLocation you will get rid of the arrow after 5-10 seconds. This works in my app. Make sure that you only have one locationManager in your whole app, and that you call stop on exactly that one. Just make sure that you really call stopUpdatingLocation:

In AppDelegate.m: 

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    NSLog(@"applicationDidEnterBackground");
    [locationManager stopUpdatingLocation];

    // optionally  
    [locationManager stopUpdatingHeading];
}

But the arrow is kept if there is any other application that uses Location Services.

AlexWien
  • 28,470
  • 6
  • 53
  • 83
  • Worked great. What is still not working is step 3: My App: 1. start App in foreground 2. start LocationManager 3. set timer (e.g.10min) 4. Go background 5. wake up every 10min, startLocManager 6. send data 7. stopLocationUpdate The Timer part does not work. Is that really an ios7 issue? – user2974818 Nov 11 '13 at 20:26
  • If you are trying get location on background for iOS 7, you may try this solution here: http://stackoverflow.com/questions/18946881/background-location-services-not-working-in-ios-7/21966662#21966662 If you have any question, you are welcomed to join us for a discussion here: http://mobileoop.com/background-location-update-programming-for-ios-7 – Ricky May 01 '14 at 15:17