【问题标题】:ionic 3 geolocation Position error in iosios中的ionic 3 geolocation位置错误
【发布时间】:2019-11-14 21:28:48
【问题描述】:

我正在使用 ionic-3 开发 Hybrid 应用程序。我正在实施google map 并试图在我的应用程序中获取当前位置。地图在 android 和浏览器中运行良好,但是当我在 ios 中构建它时,出现权限错误。我在config.xml 中添加了配置文件以获取权限

Config.xml 中的配置文件

    <config-file file="*-Info.plist" mode="merge" target="NSLocationWhenInUseUsageDescription">
        <string>To get your location and provide better service</string>
    </config-file>
    <config-file file="*-Info.plist" mode="merge" target="NSLocationAlwaysUsageDescription">
        <string>To get your location and provide better service</string>
    </config-file>
    <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
        <string>need camera to take your profile picture</string>
    </config-file>

我收到如下图所示的错误

你能建议我任何解决方案吗? 谢谢。

【问题讨论】:

  • 您是否将选项传递给 Geolocation.getCurrentPosition()?
  • 是的,我的代码是这样的 "Geolocation.getCurrentPosition().then((position) => {}"
  • 试试这个。让选项= {超时:10000,enableHighAccuracy:真}; Geolocation.getCurrentPosition(options).then((resp) => { console.log("position", resp) }).catch((error) => { console.log('error: ', error); }) ;确保使用最新的插件,并且您的 iPhone 设备中的 GPS 位置处于“开启”状态
  • 感谢您的回复,但没有帮助。我现在正在关注错误。 "操作无法完成(KCLErrorDomain error 0)"

标签: ios google-maps permissions geolocation ionic3


【解决方案1】:

最后我得到了解决方案。 我只需要设置我的模拟器当前位置。我会解释它,也许它会帮助别人。

  1. 在 iPhone 模拟器中运行项目
  2. 在“调试”菜单下,最后一个条目是“位置”;这会给你一个子菜单
  3. 选择“自定义位置”
  4. 设置您的位置。就是这样

【讨论】:

    猜你喜欢
    • 2021-07-27
    • 2018-07-22
    • 2017-11-30
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 1970-01-01
    • 2017-06-09
    • 1970-01-01
    相关资源
    最近更新 更多