Commit 78aa8a9f authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

iOS 8 - CLLocationManager authorization


iOS8 introduced a new authorization scheme for Location data.
Before retrieving location data, CLLocationManager must request authorization.
Call two methods: requestAlwaysAuthorization/requestWhenInUseAuthorization
on a location manager (which one will work/preferred - can be adjusted
by setting NSLocationAlwaysUsageDescription/NSLocationWhenInUseUsageDescription
entries in a plist).

Task-number: QTBUG-41827
Change-Id: I9fc24921dc7d889b629b2c71e7698a33fc6ae47a
Reviewed-by: default avatarAlex Blasche <alexander.blasche@digia.com>
Showing with 18 additions and 0 deletions
......@@ -137,6 +137,14 @@ bool QGeoPositionInfoSourceCL::enableLocationManager()
m_locationManager = [[CLLocationManager alloc] init];
m_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
m_locationManager.delegate = [[PositionLocationDelegate alloc] initWithInfoSource:this];
// These two methods are new in iOS 8. They require NSLocationAlwaysUsageDescription
// and NSLocationWhenInUseUsageDescription to be set in Info.plist to work (methods are
// noop if there are no such entries in plist).
if ([m_locationManager respondsToSelector:@selector(requestAlwaysAuthorization)])
[m_locationManager performSelector:@selector(requestAlwaysAuthorization)];
if ([m_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
[m_locationManager performSelector:@selector(requestWhenInUseAuthorization)];
}
return (m_locationManager != 0);
......
......@@ -376,6 +376,16 @@ QStringList QGeoPositionInfoSource::availableSources()
lost or if a hardware error is detected. Position updates will recommence if the data becomes
available later on. The updateTimeout() signal will not be emitted again until after the
periodic updates resume.
On iOS, starting from version 8, Core Location framework requires additional
entries in the application's Info.plist with keys NSLocationAlwaysUsageDescription or
NSLocationWhenInUseUsageDescription and a string to be displayed in the authorization prompt.
The key NSLocationWhenInUseUsageDescription is used when requesting permission
to use location services while the app is in the foreground.
The key NSLocationAlwaysUsageDescription is used when requesting permission
to use location services whenever the app is running (both the foreground and the background).
If both entries are defined, NSLocationWhenInUseUsageDescription has a priority in the
foreground mode.
*/
/*!
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment