diff options
author | Timur Pocheptsov <Timur.Pocheptsov@digia.com> | 2014-10-14 09:08:56 +0200 |
---|---|---|
committer | Timur Pocheptsov <Timur.Pocheptsov@digia.com> | 2014-10-23 11:37:35 +0200 |
commit | 78aa8a9f931ec4f983747869f5de5c121d194dcc (patch) | |
tree | be6bcd5d8ad8eaae1552be17a3ba13e66c6d94a7 /src/plugins/position/corelocation/qgeopositioninfosource_cl.mm | |
parent | 4aa90d773139d0ac3279514faef8ba0e285ea640 (diff) | |
download | qtlocation-78aa8a9f931ec4f983747869f5de5c121d194dcc.tar.gz |
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: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/plugins/position/corelocation/qgeopositioninfosource_cl.mm')
-rw-r--r-- | src/plugins/position/corelocation/qgeopositioninfosource_cl.mm | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm index 8ebe7018..efb5ec59 100644 --- a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm +++ b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm @@ -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); |