ios - 找出用户要求绑定(bind) BLe 设备的决定(Objective-C,iOS 10)
<p><p>iOS的绑定(bind)请求是否可以得到用户的决定?</p>
<ul>
<li>选择 1:中止</li>
<li>选择 2:连接/绑定(bind)</li>
</ul>
<p>绑定(bind)请求的屏幕截图:
<a href="/image/zwaNV.png" rel="noreferrer noopener nofollow"><img src="/image/zwaNV.png" alt="enter image description here"/></a> </p>
<p>我尝试使用 centralManagerDidUpdateState,但如果我打开蓝牙,它只会使用 CBManagerStatePoweredOn 调用一次。</p>
<pre><code>#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;
}
}
</code></pre>
<p>我也尝试使用“didConnectPeripheral”和“didFailToConnectPeripheral”:</p>
<pre><code>- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral {
;
;
;
BleDevice* bleDevice = ];
devicePaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error {
;
;
;
BleDevice* bleDevice = ];
deviceNotPaired(bleDevice.deviceId, bleDevice.primaryServiceUuid);
}
</code></pre>
<p>但是点击“Abort”或“Connect/Bond”后这两种方法都没有被调用!
至少在尝试连接到设备时只调用了“didConnectPeripheral”——但这发生在弹出窗口出现之前!</p>
<p>还有其他想法吗?</p>
<blockquote>
<p>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!</p>
</blockquote></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>不,这是不可能的。我不知道为什么 Apple 会做出这个决定,因为从安全的角度来看,应用程序知道链接是否经过正确加密和身份验证可能很重要。</p>
<p>如果您可以控制外围设备的固件,则可以使其在配对事件发生时发送有关特性的内容。</p></p>
<p style="font-size: 20px;">关于ios - 找出用户要求绑定(bind) BLe 设备的决定(Objective-C,iOS 10),我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/42369910/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/42369910/
</a>
</p>
页:
[1]