g***@qq.com
g***@qq.com
  • 发布:2021-01-27 09:59
  • 更新:2023-04-25 13:34
  • 阅读:1815

【报Bug】uni.getLocation ios 14.2 以及以上 报定位失败

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 10.14.6

HBuilderX类型: 正式

HBuilderX版本号: 2.9.8

手机系统: iOS

手机系统版本号: IOS 14

手机厂商: 苹果

手机机型: iPhone XS Max

页面类型: vue

打包方式: 离线

项目创建方式: HBuilderX

示例代码:

uni.getLocation({
type: 'wgs84',
geocode:true,
success: res => {
console.log(res.address.city);
this.city = res.address.city;
this.queryHospital({city: res.address.city});
},
fail: (e) => {
uni.hideLoading();
this.ent.toast("定位失败");
}
});

操作步骤:

直接页面中请求
uni.getLocation({
type: 'wgs84',
geocode:true,
success: res => {
console.log(res.address.city);
this.city = res.address.city;
this.queryHospital({city: res.address.city});
},
fail: (e) => {
uni.hideLoading();
this.ent.toast("定位失败");
}
});

预期结果:

走定位成功回调

实际结果:

走了fail定位失败回调

bug描述:

uni.getLocation 在ios 14.1上面没有问题,在ios 14.2及以上 都会有问题,走了fail 回调,授权页面出来了点击同意授权以后,走了fail失败回调,要么一直定位中没有任何返回

2021-01-27 09:59 负责人:无 分享
已邀请:
小白_chen

小白_chen - 前端开发工程师

请问解决了吗?我现在也是遇到这个问题,很棘手。就调试的安卓上没问题,IOS模拟器就一直报这个错误,如果有解决方案希望能贴一下,谢谢。

  • 9***@qq.com

    2023年了QAQ,我也遇到这个问题了,,地图组件用的nvue写的,,嗯是走失败回调说解析失败,,求解


    2023-02-24 13:15

rok138

rok138

我也是,uni.getLocation安卓正常,ios一直fail提示errMsg: "getLocation:fail system permission denied"

uni.getLocation({
type: 'gcj02',
success: res=> {
console.log("getLocation res#:",res)
resolve({
longitude: res.longitude,
latitude: res.latitude
})
},
fail: err=> {
console.log("err#1 getLocation",err)
resolve({
longitude: 118.59716,
latitude: 24.883448,
})
},
complete(res) {
console.log(res);
}
})

3***@qq.com

3***@qq.com

我也是

涂涛

涂涛

请问解决了吗?

l***@163.com

l***@163.com

请问有人解决了吗?在真机模拟上可以 但是只要是打包app出来 ios中都定位不了 都是走fail

4***@qq.com

4***@qq.com

请问有人解决了吗?

DCloud_heavensoft

DCloud_heavensoft

  1. 确保给app定位权限了
  2. 如果用的是高德、百度的定位,确保manifest里配了正确的key、模块打进去了。
1***@qq.com

1***@qq.com

有人解决了吗,ios真的不行,直接就走ip定位了

k***@163.com

k***@163.com - 1

IOS16
uni.getLocation({
type: 'gcj02',
geocode:true,
success: function (res) {},
fail: (err) => {}});

type:为 'gcj02',时直接不走这个方法
,wgs84 可以返回, 高德key,模块权限也给了
安卓是正常的

要回复问题请先登录注册