蓝牙接口调用需要授权问题?
发布于 5 年前 作者 leitao 11568 次浏览 来自 官方Issues

访问蓝牙、需要用户授权

  1. 小程序处理用户的个人信息,需要获取用户明示同意,平台计划从2022年2月21日24时起对以下接口增加用户授权:访问蓝牙:调用wx.openBluetoothAdapter、wx.createBLEPeripheralServer,需要授权scope.bluetooth

开发者可在平台调整前提前增加使用 wx.getSetting 获取用户当前的授权状态的逻辑,若授权状态为false可以调用 wx.openSetting 打开设置界面,引导用户开启授权。

openSetting 打开设置界面是还没有蓝牙选项 ??????????

2 回复

逻辑大概是:你可以通过 wx.getSetting 获取 scope.bluetooth 是否为 true 代表授权状态

如果 wx.getSetting 里没有 scope.bluetooth ,则要用 wx.authorize({ scope: “scope.bluetooth” }) 去弹窗要求用户授权

如果 wx.getSetting 里有 scope.bluetooth 并且为 false,则要用 wx.openSetting 引导用户手动开启授权开关。

回到顶部