微信公众号openWXDeviceLib方法调用失败?
发布于 5 年前 作者 ogu 2485 次浏览 来自 官方Issues

微信公众号使用蓝牙设备api openWXDeviceLib报错err_msg: “system:access_denied”,下面是代码和报错信息。

const jsApiList = [
            "openWXDeviceLib",//初始化设备库(只支持蓝牙设备)
            "getLocation",
           ];

let config = {
         beta: true,
         debugtrue,
         appId: signatureData.appId,
         timestamp: signatureData.timestamp,
         nonceStr: signatureData.nonceStr,
         signature: signatureData.signature,
         jsApiList: jsApiList
        };

wx.config(config)

wx.ready(function (data) {
 wx.checkJsApi({
         jsApiList: jsApiList,
         success: function (res) {
          console.log('检测的JS接口列表', res)
         }
        });

console.log('微信认证成功', JSON.stringify(data))

wx.getLocation({
 type'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
 success: function (res) {
                console.log('当前位置信息', res)
       });

wx.invoke('openWXDeviceLib', { 'brandUserName''gh_xxxxxxxxx' }, function (res) {
                                        console.log("获取设备信息:", res)
                                    })
     });
wx.error(function (err) {
               console.log('微信认证失败', JSON.stringify(err))
 });

下面是输出日志截图

微信日志已上传,上传时间 2021.07.14

机型:vivo z3 android版本9

微信版本:8.0.7

微信号:LH1375603382

社区搜了一圈了,要是新注册公众号不支持这个功能你们说下呀!要是还支持请给出解决办法.

回到顶部