Qt Positioning 在 iOS 上
从 iOS 应用程序使用Qt Positioning 服务
要让应用程序在 iOS 设备上使用定位服务,必须在 Info.plist 文件中添加条目,条目取决于应用程序使用时需要定位服务还是在后台运行时需要定位服务。
添加权限后,用户需要授予权限,使定位服务在应用请求定位服务时可用。用户可以进入 "设置">"隐私">"定位服务",向下滚动找到应用程序,然后选择一个选项来更改。定位服务必须开启才能工作。
使用前景定位服务权限
如果应用程序在运行时使用了定位服务,Info.plist 文件中需要有一个键为NSLocationWhenInUseUsageDescription
的条目,以及一个值为文本字符串的条目,向用户说明应用程序使用定位服务的原因。
<key>NSLocationWhenInUseUsageDescription</key> <string>The reason why the app needs location services</string>
使用后台定位服务权限
如果应用程序在后台运行时仍使用定位服务,则需要在NSLocationAlwaysAndWhenInUseUsageDescription
中添加一个条目,其关键字为NSLocationWhenInUseUsageDescription
,原因为字符串值。
<key>NSLocationWhenInUseUsageDescription</key> <string>The reason why the app needs location services</string> <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> <string>The reason why the app needs location services</string>
注意: Info.plist 文件是自动生成的,除非采取措施,否则所做更改可能会被 qmake 或 CMake 覆盖。更多信息,请参见平台说明 - iOS。
© 2025 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.