微信小程序:chooseLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json
最近有朋友在群里提醒,定位的功能不正常:chooseLocation:fail the api need to be declared in the requiredPrivateInfos field in app.json/ext.json
这问题的原因是微信小程序调整相关接口了……
自 2022 年 7 月 14 日后发布的小程序,使用以下8个地理位置相关接口时,需要声明该字段,否则将无法正常使用。2022 年 7 月 14 日前发布的小程序不受影响。
申明需要使用的地理位置相关接口,类型为数组。目前支持以下项目:
getFuzzyLocation: 获取模糊地理位置
getLocation: 获取精确地理位置
onLocationChange: 监听试试地理位置变化事件
startLocationUpdate: 接收位置消息(前台)
startLocationUpdateBackground: 接收位置消息(前后台)
chooseLocation: 打开地图选择位置
choosePoi: 打开 POI 列表选择位置
chooseAddress: 获取用户地址信息
配置示例:
{
"pages": ["pages/index/index"],
"requiredPrivateInfos": [
"getFuzzyLocation",
"getLocation",
"onLocationChange",
"startLocationUpdateBackground"
"chooseAddress"
]
}
如果是 uniapp 开发,可以参考:
{
"mp-weixin" : {
"appid" : "www.zhuige.com",
"requiredPrivateInfos" : ["getLocation", "chooseLocation"]
},
}
注:若使用以上接口,均需在小程序管理后台,「开发」-「开发管理」-「接口设置」中自助开通该接口权限。
开通教程:
https://www.zhuige.com/bbs/440.html
-
微信小程序转发文件到聊天API wx.shareFileMessagewx.shareFileMessage是微信小程序转发文件到聊天API。追格小编前面分享过《wx.shareVideoMessage微信小程序转发视频到聊天接口》,有兴趣的朋友可以看看。
-
微信小程序显示 loading 提示框API wx.showLoading微信小程序显示 loading 提示框API wx.showLoading,需主动调用 wx.hideLoading 才能关闭提示框。
-
微信小程序移除插屏广告关闭事件的监听函数InterstitialAd.offCloseInterstitialAd.offClose是微信小程序移除插屏广告关闭事件的监听函数。onClose 传入的监听函数。不传此参数则移除所有监听函数。
-
微信小程序wx.getExtConfig获取第三方平台自定义的数据字段wx.getExtConfig是微信小程序获取第三方平台自定义的数据字段函数。
-
wx.reportAnalytics 微信小程序自定义分析数据上报接口wx.reportAnalytics是微信小程序的自定义分析数据上报API,使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。
-
微信小程序分享到朋友圈自定义导航页面变形微信小程序朋友圈单页模式麻烦多多
暂无评论,抢个沙发...