求Native.js操作IOS蓝牙的例子或者思路
var CBCentralManager = plus.ios.importClass("CBCentralManager");
var manager = new CBCentralManager();
var delegate = plus.ios.implements("CBCentralManagerDelegate", {
"centralManagerDidUpdateState:": function(central){
var state = central.plusGetAttribute("state");
console.log("中央外设管理器状态" + JSON.stringify(central));
console.log("state=" + state);
if(state==5){
//当执行到搜索外设时就闪退,求解
central.scanForPeripheralsWithServicesoptions(null, null);
}
},
"centralManager:didDiscoverPeripheral:advertisementData:RSSI:": function(central, peripheral, advertisementData, RSSI) {
console.log("central:"+JSON.stringify(central))
console.log("peripheral:"+JSON.stringify(peripheral))
console.log("advertisementData:"+JSON.stringify(advertisementData))
console.log("RSSI:"+JSON.stringify(RSSI))
var name = peripheral.plusGetAttribute("name");
var uuid = peripheral.plusGetAttribute("identifier").plusGetAttribute("UUIDString");
var rssi = RSSI.plusGetAttribute("intValue");
}
});
manager.initWithDelegatequeue(delegate, null);
4 个回复
KyleFu (作者)
"frameworks": [
"CoreBluetooth.framework",
"CoreLocation.framework",
"CoreGraphics.framework",
"UIKit.framework",
"Foundation.framework"] /调用Native.js调用原生Objective-c API需要引用的FrameWork,如需调用GameCenter,则添加"GameKit.framework"/
已经引用了相关的框架
KyleFu (作者)
继续等待,期待大神
1***@qq.com
我也闪退,mlgb的掉进大坑里了
w***@qq.com
别想了Native.js搞不定的
1***@qq.com
搞不定你怎么还天天在提问
2018-04-14 19:47
8***@qq.com
怎么才能搞定啊.指导一下啊,大佬....
2018-07-06 09:24