Reputation: 41
My app requires users current location to show him direction to a particular location in google map
Below is the code to show location on web view-
[self.getDirectionsWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude,self.projectLatitude,self.projectLongitude]]]];
The app declares support for location in .plist by using NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[locationManager requestAlwaysAuthorization];
}
[locationManager startUpdatingLocation];
Apple rejected the app with following reason
2.16 Details
Your app declares support for location in the UIBackgroundModes key in your Info.plist file but still does not declare any features that require persistent location. Apps that declare support for location in the UIBackgroundModes key in your Info.plist file must have features that require persistent location.
Specifically, we noticed that the Directions feature does not require persistent location information, since it does not include turn-by-turn navigation.
Any help will be appreciated, Thanks in Advance.
Upvotes: 4
Views: 7863
Reputation: 689
It's is not necessary to request the background mode to request the user's current location.
I would recommend to use NSLocationWhenInUseUsageDescription if you don't need to use the user's location in background. Users are more inclined to deny the user location authorization when they see NSLocationAlwaysUsageDescription because they think that reduce the device's battery
Upvotes: 1
Reputation: 881423
Based on:
It looks like they're stating you shouldn't need location information unless the app is actually active. Since the location information is used to show the user the direction they need to head in, you should be able to simply adjust (with a little latency of course) when your app comes to the fore.
From Apple's documentation:
UIBackgroundModes (Array - iOS) specifies that the app provides specific background services and must be allowed to continue running while in the background.
These keys should be used sparingly and only by apps providing the indicated services. Where alternatives for running in the background exist, those alternatives should be used instead.
For example, apps can use the significant location change interface to receive location events instead of registering as a background location app.
That'd be my analysis though it's equally likely that the reviewer just had an argument with their significant other that morning, and is just being capricious :-) Nah, just joking, but it does sometimes seem to outsiders that the decisions they make are, shall we say, less than perfectly consistent.
Upvotes: 4
Reputation: 601
You just remove the location support from UIBackgroundModes
key in info.plist
As you must only use UIBackgroundModes
for location when you want to fetch location when your app is in background.
In your app declaration of NSLocationAlwaysUsageDescription
and NSLocationWhenInUseUsageDescription
is enough.
Upvotes: 11