gpt4 book ai didi

ios - 获取经典蓝牙连接设备列表(无 BLE)[EAAccessoryManager]

转载 作者:可可西里 更新时间:2023-11-01 04:45:17 35 4
gpt4 key购买 nike

我需要做一个应用程序来判断我当前是否连接到经典蓝牙设备(实际上,它将是蓝牙汽车设备)。

我的第一步是告诉当前连接的经典蓝牙设备有哪些。我不能使用 CoreBluetooth,因为它仅适用于 LE。我尝试使用外部附件框架。

这是代码(一个按钮启动方法):

- (IBAction)startMethodGetConnected:(id)sender {
NSLog(@"button taped");
// Get the number of accessories connected
NSUInteger NumberOfAccessoriesConnected = [[EAAccessoryManager sharedAccessoryManager].connectedAccessories count];
//Display the number
NSLog(@"number of accessories connected : %d", NumberOfAccessoriesConnected);
}

当 iPhone 连接到蓝牙键盘和蓝牙耳机时,我已经尝试过。在这两种情况下,控制台都显示数字为 0。

如何显示正确的数字?

最佳答案

来自苹果文档:

"Applications that support external accessories must be sure to configure their Info.plist file correctly. Specifically, you must include the UISupportedExternalAccessoryProtocols key to declare the specific hardware protocols your application supports. For more information about this framework, see External Accessory Programming Topics." here

您需要使用 MFi 设备的协议(protocol)将此 key 添加到您的 Info.plist 文件中。

<key>UISupportedExternalAccessoryProtocols</key>
<array>
<string>your_protocol_name</string>
</array>

问候

关于ios - 获取经典蓝牙连接设备列表(无 BLE)[EAAccessoryManager],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35495738/

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