是否可以让用户决定iOS的绑定请求?
我尝试使用centralManagerDidUpdateState,但如果我打开蓝牙,它只用CBManagerStatePoweredOn调用一次。
#pragma mark - CBCentralManagerDelegate
- (void)centralManagerDidUpdateState:(CBCentralManager *)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)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
[peripheral setDelegate:self];
[self _cancelConnectionRequests];
[peripheral discoverServices:nil];
BleDevice* bleDevice = [knownDevices findDevice:[peripheral.identifier UUIDString]];
devicePaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
[peripheral setDelegate:self];
[self _cancelConnectionRequests];
[peripheral discoverServices:nil];
BleDevice* bleDevice = [knownDevices findDevice:[peripheral.identifier UUIDString]];
deviceNotPaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
但点击" Abort"或者"连接/绑定"! 至少只有" didConnectPeripheral"在尝试连接到设备时调用 - 但这会在弹出窗口出现之前发生!
还有其他想法吗?
注意:扫描,连接或粘接时没有问题 BLe设备 - 我只想知道用户是否接受了 来自他的iPhone的粘合请求!
答案 0 :(得分:0)
不,这是不可能的。我不知道为什么Apple做出这个决定,因为从安全的角度来看,应用程序知道链接是否经过适当加密和验证可能很重要。
如果您可以控制外围设备的固件,则可以在配对事件发生时发送特性信息。