gpt4 book ai didi

ios - 找出用户要求绑定(bind) BLe 设备的决定(Objective-C,iOS 10)

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:25:24 26 4
gpt4 key购买 nike

是否可以让用户决定iOS的绑定(bind)请求?

  • 选择 1:放弃
  • 选择 2:连接/绑定(bind)

绑定(bind)请求截图: enter image description here

我尝试使用 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”或“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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com