0

如果发现新设备,则向用户推送通知。如何开始以及任何资源/示例代码?

4

1 回答 1

2

之前的三个答案都是错误的。iOS5 引入了Core 蓝牙框架

但是,此框架仅适用于 BT 4.0 LE;毫无疑问的蓝牙。

这里也是 PDF 参考:http: //developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/CoreBluetooth_Framework.pdf

例子

你的类必须符合CBCentralManagerDelegateCBPeripheralDelegate协议。

CBCentralManager * btCentral = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

/* Create an array of services from a CBUUID to scan for */
[btCentral scanForPeripheralsWithServices:nil options:nil];

这基本上是为了让您开始扫描外围设备。您还需要实现这些CBCentralManagerDelegate方法和其他一些方法,我建议您阅读文档:

- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral

- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI

- (void)centralManager:(CBCentralManager *)central didRetrieveConnectedPeripherals:(NSArray *)peripherals
于 2012-09-07T02:40:49.687 回答