diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-19 12:51:18 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-02-19 12:51:18 +0100 |
commit | 677833d418176e46babbd7720b1160ce789c7e2d (patch) | |
tree | cb04512f506755506f5900729c34f3c2e2143590 /src/plugins | |
parent | 7d46b52172f2a53e99a8aad5e59dbe9fb4f8738c (diff) | |
parent | b9d4da55cf0b775467df43c1d868dc4d58b96b45 (diff) | |
download | qtlocation-677833d418176e46babbd7720b1160ce789c7e2d.tar.gz |
Merge remote-tracking branch 'origin/5.10' into 5.11
Conflicts:
src/location/declarativemaps/qdeclarativegeomap.cpp
src/location/maps/qgeomap.cpp
src/location/maps/qgeomap_p_p.h
src/location/maps/qgeorouteparserosrmv5.cpp
src/location/maps/qgeotiledmap.cpp
src/positioning/positioning.pro
Change-Id: I42f8b176a8f3e824c7fe5b067a958735173f0dbb
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/position/corelocation/corelocation.pro | 2 | ||||
-rw-r--r-- | src/plugins/position/corelocation/qgeopositioninfosource_cl.mm | 31 |
2 files changed, 19 insertions, 14 deletions
diff --git a/src/plugins/position/corelocation/corelocation.pro b/src/plugins/position/corelocation/corelocation.pro index 947a1d0c..85a5aaed 100644 --- a/src/plugins/position/corelocation/corelocation.pro +++ b/src/plugins/position/corelocation/corelocation.pro @@ -1,6 +1,6 @@ TARGET = qtposition_cl -QT = core positioning +QT = core core-private positioning OBJECTIVE_SOURCES += \ qgeopositioninfosource_cl.mm \ diff --git a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm index 3fac056e..94c5b807 100644 --- a/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm +++ b/src/plugins/position/corelocation/qgeopositioninfosource_cl.mm @@ -40,6 +40,7 @@ #include <QTimerEvent> #include <QDebug> #include <QtCore/qglobal.h> +#include <QtCore/private/qglobal_p.h> #include "qgeopositioninfosource_cl_p.h" @@ -141,15 +142,17 @@ bool QGeoPositionInfoSourceCL::enableLocationManager() if (!m_locationManager) { m_locationManager = [[CLLocationManager alloc] init]; -#ifdef Q_OS_IOS - NSDictionary<NSString *, id> *infoDict = [[NSBundle mainBundle] infoDictionary]; - if (id value = [infoDict objectForKey:@"UIBackgroundModes"]) { - if ([value isKindOfClass:[NSArray class]]) { - NSArray *modes = static_cast<NSArray *>(value); - for (id mode in modes) { - if ([@"location" isEqualToString:mode]) { - m_locationManager.allowsBackgroundLocationUpdates = YES; - break; +#if defined(Q_OS_IOS) || defined(Q_OS_WATCHOS) + if (__builtin_available(watchOS 4.0, *)) { + NSDictionary<NSString *, id> *infoDict = [[NSBundle mainBundle] infoDictionary]; + if (id value = [infoDict objectForKey:@"UIBackgroundModes"]) { + if ([value isKindOfClass:[NSArray class]]) { + NSArray *modes = static_cast<NSArray *>(value); + for (id mode in modes) { + if ([@"location" isEqualToString:mode]) { + m_locationManager.allowsBackgroundLocationUpdates = YES; + break; + } } } } @@ -162,10 +165,12 @@ bool QGeoPositionInfoSourceCL::enableLocationManager() // 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)]; +#ifndef Q_OS_MACOS +#ifndef Q_OS_TVOS + [m_locationManager requestAlwaysAuthorization]; +#endif + [m_locationManager requestWhenInUseAuthorization]; +#endif } return (m_locationManager != 0); |