iOS的绑定(bind)请求是否可以得到用户的决定?
我尝试使用 centralManagerDidUpdateState,但如果我打开蓝牙,它只会使用 CBManagerStatePoweredOn 调用一次。
#pragma mark - CBCentralManagerDelegate
- (void)centralManagerDidUpdateStateCBCentralManager *)central {
info(@"centralManagerDidUpdateState");
switch(central.state){
case CBManagerStateUnauthorized:
info(@"unauthorized");
break;
case CBManagerStatePoweredOff:
info(@"poweredOff");
break;
case CBManagerStatePoweredOn:
info(@"poweredOn");
break;
case CBManagerStateResetting:
info(@"resetting");
break;
case CBManagerStateUnknown:
info(@"unknown");
break;
case CBManagerStateUnsupported:
info(@"unsupported");
break;
}
}
我也尝试使用“didConnectPeripheral”和“didFailToConnectPeripheral”:
- (void)centralManagerCBCentralManager *)central didConnectPeripheralCBPeripheral *)peripheral {
[peripheral setDelegate:self];
[self _cancelConnectionRequests];
[peripheral discoverServices:nil];
BleDevice* bleDevice = [knownDevices findDevice:[peripheral.identifier UUIDString]];
devicePaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
- (void)centralManagerCBCentralManager *)central didFailToConnectPeripheralCBPeripheral *)peripheral errorNSError *)error {
[peripheral setDelegate:self];
[self _cancelConnectionRequests];
[peripheral discoverServices:nil];
BleDevice* bleDevice = [knownDevices findDevice:[peripheral.identifier UUIDString]];
deviceNotPaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
但是点击“Abort”或“Connect/Bond”后这两种方法都没有被调用! 至少在尝试连接到设备时只调用了“didConnectPeripheral”——但这发生在弹出窗口出现之前!
还有其他想法吗?
Note: I have no problems with scanning, connecting or bonding with a BLe device - I only want to know if the user accepted the bonding-request from his iPhone!
不,这是不可能的。我不知道为什么 Apple 会做出这个决定,因为从安全的角度来看,应用程序知道链接是否经过正确加密和身份验证可能很重要。
如果您可以控制外围设备的固件,则可以使其在配对事件发生时发送有关特性的内容。
关于ios - 找出用户要求绑定(bind) BLe 设备的决定(Objective-C,iOS 10),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42369910/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |