Qt Positioning Core Location plugin

Overview

The plugin wraps iOS and macOS positioning subsystems. It is only available on Apple platforms that support corelocation. The plugin provides only positioning information.

This plugin can be loaded by using the provider name corelocation.

Parameters

The following table lists parameters that can be passed to the corelocation plugin.

ParameterDescription
RequestAlwaysPermissionAsk permissions for using location not only while using the application, but also in background. The parameter is a bool, so it accepts either true or false. If the parameter is not specified, it is considered to be false.

On iOS, the application can ask for two levels of location permissions:

  • When In Use - makes location updates available only when someone uses your app.
  • Always - makes location updates available at any time, and lets the system launch your app quietly to handle some updates.

By default, only the When In Use permission is requested. The RequestAlwaysPermission parameter is used to explicitly reqeust for Always permission.

Position source usage example

The following examples show how to create a corelocation PositionSource using different permission levels.

QML

// default - When In Use permission.
PositionSource {
    name: "corelocation"
}

// RequestAlwaysPermission = false. Same as default.
PositionSource {
    name: "corelocation"
    PluginParameter { name: "RequestAlwaysPermission"; value: false }
}

// RequestAlwaysPermission = true. Request Always permission.
PositionSource {
    name: "corelocation"
    PluginParameter { name: "RequestAlwaysPermission"; value: true }
}

C++

// default - When In Use permission.
QGeoPositionInfoSource *defaultSource
                = QGeoPositionInfoSource::createSource("corelocation", this);

// RequestAlwaysPermission = false. Same as default.
params["RequestAlwaysPermission"] = false;
QGeoPositionInfoSource *whenInUseSource
                = QGeoPositionInfoSource::createSource("corelocation", params, this);

// RequestAlwaysPermission = true. Request Always permission.
params["RequestAlwaysPermission"] = true;
QGeoPositionInfoSource *alwaysSource
                = QGeoPositionInfoSource::createSource("corelocation", params, this);

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.