For AI agents: the complete documentation index is available at /apps-plugin/docs/llms.txt, the full documentation bundle is available at /apps-plugin/docs/llms-full.txt, and this page is available as Markdown at /apps-plugin/docs/js-api/location/onLocationChangeError.md.

onLocationChangeError

注册位置更新异常回调。

支持版本

前端库版本不低于 0.0.32。

支持平台

平台支持情况
Android支持
iOS支持
PC不支持
HarmonyOS不支持

支持场景

场景支持情况
页面支持
卡片不支持

使用说明

  • 建议在调用 startLocationUpdate 前注册;不再使用时调用返回的取消函数释放当前监听

调用方式

事件监听 API

onLocationChangeError(callback: LocationChangeErrorListener): () => void

入参

无。

调用示例

import { onLocationChangeError } from '@doubao-dev/framework/api';

const unsubscribe = onLocationChangeError(({ errMsg, errCode }) => {
  console.log(errMsg, errCode);
});

unsubscribe();

回调参数

名称类型必返说明
event.errCodenumber否错误码
event.errMsgstring是错误信息

返回值

返回取消当前监听函数的函数。

回调示例

{
  "errMsg": "location_timeout",
  "errCode": 0
}

错误处理

错误对象和通用错误码见 通用错误处理。

失败示例

{
  "errMsg": "location_timeout",
  "errCode": 0
}

错误码

事件错误码

错误字段值错误信息平台触发条件处理建议
event.errCode0-Android持续定位过程中发生异常结合 errMsg 检查系统定位服务、权限和网络环境
event.errCode0location_timeoutiOS系统定位超时稍后重试,并检查定位环境
event.errCode1location_service_disablediOS系统定位服务已关闭在系统设置中开启定位服务
event.errCode25location_permission_deniediOS尚未完成系统定位授权重新发起授权后重试
event.errCode27location_permission_deniediOS用户拒绝系统定位权限引导用户在系统设置中开启定位权限
event.errCode29location_permission_deniediOS系统限制定位权限提示用户检查系统限制设置

平台差异

  • iOS:其他系统定位异常会保留原始 errCode 并返回 location_fail;位置结果无效时事件中可能不包含 errCode