// let arr = state.centralManager.retrieveConnectedPeripheralsWithServices();
// let arr = state.centralManager.retrieveConnectedPeripheralsWithServices(null);
// console.log("2. 中央外设管理器状态 state= ", arr);
var CBCentralManager = plus.ios.importClass("CBCentralManager");
var manager = new CBCentralManager();
var delegate = plus.ios.implements("CBCentralManagerDelegate", {
"centralManagerDidUpdateState:": function(State) {
var www = State.plusGetAttribute('state');
if (www == 4) {
console.log('请开启蓝牙');
}
console.log("2. 中央外设管理器状态 state= " + www);
console.log(JSON.stringify(www));
}
});
manager.initWithDelegatequeue(delegate,null);
console.log('1、开始扫描蓝牙外设....');
manager.scanForPeripheralsWithServicesoptions(null, null);
目前我在uniapp里面写的代码是这样的, 不管是 retrieveConnectedPeripheralsWithServices 还是 scanForPeripheralsWithServicesoptions 都会使app 闪退。有成功的例子吗?处理蓝牙方面的
0 个回复