1

I am using following code for location-

self.locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    locationManager.desiredAccuracy=500;
    locationManager.distanceFilter=kCLLocationAccuracyKilometer;


#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000

    if ([locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
    {
        [locationManager requestAlwaysAuthorization];
    }
#else


#endif

    [locationManager startUpdatingLocation];

    //Disable auto location pause in background
    if ([self.locationManager respondsToSelector:@selector(pausesLocationUpdatesAutomatically)])
    {
        self.locationManager.pausesLocationUpdatesAutomatically = NO;
    }

And in my plist file I used "App registers for location updates" for "Required background modes". But apple rejected my application and says you have to use real time location updates if you are using location in background.

Please let me know what I need to use if I want to use location in background with distancefilter.

Ravi Gautam
  • 960
  • 2
  • 9
  • 20

1 Answers1

0

If you want to have background updates without the "App registers for location updates" background mode you have to usestartMonitoringSignificantLocationChanges. It should generate location updates in background every few kilometers. There's no other way to get location updates in background (without the background mode).

Apple documentation

. startMonitoringSignificantLocationChanges doesn't rely on the filter:

It does not rely on the value in the distanceFilter property to generate events.

EDIT:

As I mentioned in the comments, you can use background audio like the RunKeeper app does. It's still a gray area, meaning there's a big chance your app will be still rejected

CoreMotion updates in background state

Community
  • 1
  • 1
michal.ciurus
  • 3,616
  • 17
  • 32
  • Thanks for reply. I am counting steps with motion sensor below iPhone5s devices, so I need to alive my application in background. Is there any other way to do that. – Ravi Gautam Mar 03 '15 at 17:38
  • Yes, there are some tricks like running music in background. But the result is the same as with location update: you still need background mode enabled => it will probably get rejected by apple. – michal.ciurus Mar 03 '15 at 17:42
  • I am using M7 chip for iPhone5s and above but what on 4,4s,5 and 5c – Ravi Gautam Mar 03 '15 at 18:09
  • If you want to ask about m7 and core motion you have to create another question. This is way out of topic. Please mark my question as correct if I answered your original question. – michal.ciurus Mar 03 '15 at 18:19