var CBCentralManager = plus.ios.importClass("CBCentralManager");
var manager = new CBCentralManager();
var delegate = plus.ios.implements("CBCentralManagerDelegate", {
"centralManagerDidUpdateState:": function(State){
var state = State.plusGetAttribute('state');
if (state == 4) {
console.log('请开启蓝牙');
}
console.log("2. 中央外设管理器状态 state= " + state);
console.log(JSON.stringify(State));
},
"centralManager:didDiscoverPeripheral:advertisementData:RSSI:":function(central, peripheral, advertisementData, RSSI){
console.log('4. 发现蓝牙外设 didDiscoverPeripheral')
console.log('<br>central=' + JSON.stringify(central));
//为什么能发现,但获取不到蓝牙设备,以下三个值均返回 undefined
console.log('<br>peripheral=' + JSON.stringify(peripheral));
console.log('<br>advertisementData=' + JSON.stringify(advertisementData));
console.log('<br>RSSI=' + JSON.stringify(RSSI));
}
});
manager.initWithDelegatequeue(delegate,null);
console.log('1、开始扫描蓝牙外设....');
manager.scanForPeripheralsWithServicesoptions(null, null);
为什么无法执行到"centralManager:didDiscoverPeripheral:advertisementData:RSSI:"这个方法里呢,请大神赐教
2 个回复
Bana
解决了吗,我这边也不走这个方法
Bana
貌似目前只支持 离线打包 + 本地插件形式
1***@qq.com
坑呀
2018-04-08 23:56