8***@qq.com
8***@qq.com
  • 发布:2025-05-29 17:18
  • 更新:2025-05-29 17:53
  • 阅读:43

【报Bug】 uni.onLocationChange 方法回调在ios系统不持续执行,只有从后太切前台执行一次

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 15.2 (24C101)

HBuilderX类型: 正式

HBuilderX版本号: 4.66

手机系统: iOS

手机系统版本号: iOS 18

手机厂商: 苹果

手机机型: iphone13

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

// 实时定位取坐标  
const locationChange = (res2) => {  
  console.log(res2.longitude + "," + res2.latitude)  
      uni.showModal({  
        title: "定位更新了",  
        content: res2.longitude + "," + res2.latitude,  
        showCancel: false,  
        confirmText: "确定",  
        success: function (res) {},  
      })  
}  
// 实时定位请求错误  
const locationChangeError = () => {  
  uni.stopLocationUpdate()  
}   
 onShow(()=>{  
uni.startLocationUpdate({  
      type: "gcj02",  
      success: (res) => {  
        uni.onLocationChange(locationChange)  

        uni.onLocationChangeError(locationChangeError)  

      },  
      fail: (err) => {  
      },  
      complete: (msg) => {  
        console.log("调用开启小程序接收位置消息 API 完成")  
      },  
    })  
})  ``` 

操作步骤:

上述代码可以复现

预期结果:

预期回调会持续执行拿到回调

实际结果:

uni.onLocationChange() 回调不执行 只有从后台切到前台时 会执行一次

bug描述:

iphone13 进入签到页面onshow调用代码事例方法 uni.startLocationUpdate 方法会执行 uni.onLocationChange回调方法不执行, 只有把app切换到后台在切换到前台时 uni.onLocationChange方法会执行,也会拿到坐标参数等, 但是只执行一次,后续不会执行,测试在走动过程中也不会执行,走路大概200米没有回调执行,安卓系统正常 大概每一秒执行一次回调 manifest.json配置了权限与模块

2025-05-29 17:18 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com

安卓版可以加个定时器,苹果版授权要完善,不然无法实时更新

  • 8***@qq.com (作者)

    苹果还需要授权什么么 方便告诉下么 我配置了权限和模块

    2025-05-30 08:31

要回复问题请先登录注册