微信小程序使用web-view,调用监听ibeacon的JSSDK时无效,怎么解决?
看到有回答说微信停用了摇一摇的功能,可小程序官方文档里还是写了支持这个功能的。
流程如下:
配置wx.config后开始调用jssdk
_this.wx.startSearchBeacons({
ticket: '',
complete(argv) {
if (argv.errMsg === 'startSearchBeacons:ok') {
console.info('onSearchBeacons in');
_this.wx.onSearchBeacons({
complete(argv2) {
//回调函数
console.info(argv2);
}
});
}
}
}).catch((err) => {
_this.$Indicator.close();
console.info('startSearchBeacons err');
console.info(err);
});
结果是:
startSearchBeacons:有效,返回 {"errMsg": "startSearchBeacons:ok"}
onSearchBeacons:接口一点反应都没有
有看到帖子https://developers.weixin.qq.com/community/develop/doc/000e647d288e609cf9982ce5855c00?highLine=onSearchBeacons说官方已经停用了摇一摇功能,但是官方web-view里的jssdk写着支持监听ibeacon。
找到方法了,通过改变url的hash进行传值。