1

my app update (1.1) was rejected because of this reason: We found that your app uses a background mode but does not include functionality that requires that mode to run persistently.

But my app still uses the same functionality in version 1.0.

What i do: On location update i check if the new location is inside a specific region (rectangle):

- (BOOL)locationInRegion: (CLLocation *) lastLocation {
    if ((lastLocation.coordinate.latitude < self.overlayTopLeftCoordinate.latitude && lastLocation.coordinate.latitude > self.overlayBottomLeftCoordinate.latitude) &&
        (lastLocation.coordinate.longitude < self.overlayTopRightCoordinate.longitude && lastLocation.coordinate.longitude > self.overlayTopLeftCoordinate.longitude)) {
        return YES;
    }
    return NO;
}

In Foreground and in background mode if the user is in this region i draw a crumb path on a MKMapView. If not, i do nothing.

Require background modes -> app registers for location updates is in my .plist

What i am doing wrong?

I do not have this information in my description:

Continued use of GPS running in the background can dramatically decrease battery life.

Can this be the (only) reason?

Ricky
  • 10,485
  • 6
  • 36
  • 49
q0re
  • 1,401
  • 19
  • 32
  • Drawing info while in background? This doesn't seem very useful... – Macmade May 27 '14 at 08:29
  • the app shows a mapview with a custom theme park overlay. and on location update a crumb path is drawn on the map that the user can see which attraction he already visited.. – q0re May 27 '14 at 08:35

2 Answers2

1

There are 2 possible reasons that your app is rejected.

It is either:-

a) Your app does not need location update when it is in the background.

b) Your app does not handle the background location updates properly

If it is the latter, you will need to handle the location update and also the background tasks when it is in the background. You will need something like this

- (id)init {
   if (self==[super init]) {
    //Get the share model and also initialize myLocationArray
    self.shareModel = [LocationShareModel sharedModel];
    self.shareModel.myLocationArray = [[NSMutableArray alloc]init];

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
 }
 return self;
}

-(void)applicationEnterBackground{
  CLLocationManager *locationManager = [LocationTracker sharedLocationManager];
  locationManager.delegate = self;
  locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
  locationManager.distanceFilter = kCLDistanceFilterNone;
  [locationManager startUpdatingLocation];

  //Use the BackgroundTaskManager to manage all the background Task
  self.shareModel.bgTask = [BackgroundTaskManager sharedBackgroundTaskManager];
  [self.shareModel.bgTask beginNewBackgroundTask];
}

The above is only a snippet of the complete solution. I have shared a complete solution that is uploaded to Github and also a blog post on how to continuously get location update in the background for iOS 7 here: Background Location Services not working in iOS 7 .

Community
  • 1
  • 1
Ricky
  • 10,485
  • 6
  • 36
  • 49
  • hello, do i need any additional coding work to update the user location in the background? So far it was enough to add the `app registers for location updates` to the .plist. If i delete this in the plist i don't get any updates in background. – q0re May 27 '14 at 08:52
  • Yes, if you need the background location update, then you will need extra code. I already have a full solution on Github which will save you a lot of time in experimenting. Visit my blog too. A lot of comments and questions sent by different developers. – Ricky May 27 '14 at 08:54
  • i have debugged into `- (void)locationManager:(CLLocationManager*)manager didUpdateLocations:(NSArray *)locations` and i get updates if the app is in background mode. If i delete the background mode from the plist, i dont get any updates. So why i should need extra code? – q0re May 27 '14 at 09:00
  • The keyword is **persistently**. Try to run your current app and let it run for over 1 hour. Since it has been rejected by Apply, I am 99% sure that you app will be moved from **background mode** to **suspended mode**, then it will not get the location update anymore until you tap on the app again to move it to **active mode**. Go to read my blog and also download the solution from the Github to understand everything. – Ricky May 27 '14 at 09:07
  • thank you, that was the missing information i don't understand – q0re May 27 '14 at 09:10
  • I got it to work. Can i reduce the time between stop (after 10 secs) and restart? – q0re May 27 '14 at 09:43
  • Yes, you may. But from my experience, it is best to give the locationManager some time to get the locations. Sometimes, due to some reasons, locationManager is unable to get the location instantly. If the previous post that I posted on stackoverlow helps you, please upvote on that too. Thanks. – Ricky May 27 '14 at 09:49
0

Yes, if you fail to add following warning text in your app description and you have enabled background-location mode, Apple will reject your app.

Continued use of GPS running in the background can dramatically decrease battery life.
Zee
  • 1,865
  • 21
  • 42