diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-23 03:00:25 +0200 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2018-10-23 03:00:25 +0200 |
commit | 5c41bffd2ff58a8d55b3da1eaaebee90c327445a (patch) | |
tree | 59ae80223249cdbb52695dfc6fabfca0fe0846cc /src/plugins/position | |
parent | a12c89edd81dbacff85e4c34b7a017143abe8c0c (diff) | |
parent | 448b3a35cea27878a3123ec7e40f875032dd3267 (diff) | |
download | qtlocation-5c41bffd2ff58a8d55b3da1eaaebee90c327445a.tar.gz |
Merge remote-tracking branch 'origin/5.12' into dev
Change-Id: If8bb4158f9a46ad703c73fff5bf0b1a0636c4b5e
Diffstat (limited to 'src/plugins/position')
-rw-r--r-- | src/plugins/position/corelocation/qgeopositioninfosource_cl.mm | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm index 976ecf0f..421f7743 100644 --- a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm +++ b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm @@ -194,18 +194,29 @@ bool QGeoPositionInfoSourceCL::enableLocationManager() 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). + // -requestAlwaysAuthorization is available on iOS (>= 8.0) and watchOS (>= 2.0). + // This method requires both NSLocationAlwaysAndWhenInUseUsageDescription and + // NSLocationWhenInUseUsageDescription entries present in Info.plist (otherwise, + // while probably a noop, the call generates a warning). + // -requestWhenInUseAuthorization only requires NSLocationWhenInUseUsageDescription + // entry in Info.plist (available on iOS (>= 8.0), tvOS (>= 9.0) and watchOS (>= 2.0). + #ifndef Q_OS_MACOS + NSDictionary<NSString *, id> *infoDict = NSBundle.mainBundle.infoDictionary; + const bool hasAlwaysUseUsage = !![infoDict objectForKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"]; + const bool hasWhenInUseUsage = !![infoDict objectForKey:@"NSLocationWhenInUseUsageDescription"]; #ifndef Q_OS_TVOS - [m_locationManager requestAlwaysAuthorization]; -#endif - [m_locationManager requestWhenInUseAuthorization]; -#endif + if (hasAlwaysUseUsage && hasWhenInUseUsage) + [m_locationManager requestAlwaysAuthorization]; + else +#endif // !Q_OS_TVOS + if (hasWhenInUseUsage) + [m_locationManager requestWhenInUseAuthorization]; +#endif // !Q_OS_MACOS + } - return (m_locationManager != 0); + return (m_locationManager != nullptr); } void QGeoPositionInfoSourceCL::setTimeoutInterval(int msec) |