summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-10-14 09:08:56 +0200
committerTimur Pocheptsov <Timur.Pocheptsov@digia.com>2014-10-23 11:37:35 +0200
commit78aa8a9f931ec4f983747869f5de5c121d194dcc (patch)
treebe6bcd5d8ad8eaae1552be17a3ba13e66c6d94a7
parent4aa90d773139d0ac3279514faef8ba0e285ea640 (diff)
downloadqtlocation-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>
-rw-r--r--src/plugins/position/corelocation/qgeopositioninfosource_cl.mm8
-rw-r--r--src/positioning/qgeopositioninfosource.cpp10
2 files changed, 18 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);
diff --git a/src/positioning/qgeopositioninfosource.cpp b/src/positioning/qgeopositioninfosource.cpp
index 70d9d4ad..45d04263 100644
--- a/src/positioning/qgeopositioninfosource.cpp
+++ b/src/positioning/qgeopositioninfosource.cpp
@@ -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.
*/
/*!