简体   繁体   English

ios9和ios8之间出现意外的蓝牙对提示

[英]Unexpected bluetooth pair prompt between ios9 and ios8

I'm building an iOS app that uses Core Bluetooth (BLE) and acts as both, a peripheral (in the background) and a central when in the foreground, to communicate with anyone else running the same app nearby. 我正在构建一个使用Core Bluetooth(BLE)并同时充当外围设备 (在后台)和中央 设备 (在前台时)的iOS应用程序,以与附近运行同一应用程序的任何其他用户进行通信。

I'm noticing that when the app is on iOS9 (specifically) and running in central mode in the foreground scanning for peripherals, it automatically gets a prompt to pair with the nearby device! 我注意到,当该应用程序(特别是在iOS9上 )并在前台扫描外围设备的中央模式下运行时,它会自动提示您与附近的设备配对!


Bluetooth Pairing Request 蓝牙配对请求

"iPhone" would like to pair with your “ iPhone”想与您的配对
iPhone. 苹果手机。 Confirm that the code 确认验证码
"701958" is shown on "iPhone". “ iPhone”上显示“ 701958”。

[Cancel] [ Pair ] [取消] [ 配对 ]


Example: http://i.stack.imgur.com/D6sgg.png 示例: http//i.stack.imgur.com/D6sgg.png

This is happening despite the fact that I'm not using encryption in my peripheral's characteristic setup anywhere! 尽管我没有在任何地方的外设特征设置中使用加密,但这种情况仍在发生! It's a simple characteristic with the property value set to " CBCharacteristicPropertyRead " and permissions set to " CBAttributePermissionsReadable ". 这是一个简单的特征,其属性值设置为“ CBCharacteristicPropertyRead ”,权限设置为“ CBAttributePermissionsReadable ”。 Also note that the characteristic is setup to be a static value , not a dynamic one, and it's meant to be read directly without the need for subscribing for notifications. 还要注意,将特征设置为静态值 ,而不是动态 ,并且可以直接读取它,而无需订阅通知。

Peripheral (characteristic setup): 外围设备(特性设置):

CBMutableCharacteristic *characteristic = [[CBMutableCharacteristic alloc]
                                           initWithType:[CBUUID UUIDWithString:uuidStr]
                                           properties:CBCharacteristicPropertyRead
                                           value:myData
                                           permissions:CBAttributePermissionsReadable];

Central (trying to connect): 中央(尝试连接):

[self.centralManager connectPeripheral:peripheral options:nil];

The prompt seems to get initiated the moment my iOS9 central initiates a connection request to the discovered iOS8 peripheral device. 我的iOS9中心向发现的iOS8外围设备发起连接请求时,提示似乎已启动。

Anyone else running into this? 还有其他人遇到吗? This same piece of code has been working great between iOS8<->8, iOS7<->7, iOS8<->7, and even iOS9<->9 (at least as observed in my own testing so far). 这段代码在iOS8 <-> 8,iOS7 <-> 7,iOS8 <-> 7甚至iOS9 <-> 9(甚至到目前为止在我自己的测试中观察到的)之间都非常有效。

Any advice will be very helpful! 任何建议将非常有帮助!

Received the official response from Apple: 收到苹果公司的官方回复:

This has been determined to be caused by a bug in iOS 8. Your best course of action would be to upgrade to iOS 9 on the effected devices, and urge your users to do the same to avoid the issue. 已经确定这是由iOS 8中的错误引起的。您最好的做法是在受影响的设备上升级到iOS 9,并敦促您的用户这样做以避免出现此问题。

So there you have it. 所以你有它。 Known issue in iOS 8. Move to iOS 9. :/ iOS 8中的已知问题。移至iOS9。:/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM