如何检测 iPhone 状态栏中蓝牙图标的状态?
正如问题所述,有没有办法查询状态栏的当前图标以及它们正在使用哪个 png?如果我可以这样做,我就可以测试蓝牙是否打开以及是否连接了设备。我想指出,这与使用 EAAccessory 不同,后者是不同的连接。在本例中,我只是尝试确定是否连接了耳机,而不管 EAAccessory 状态如何。
As the question states, is there a way to query the status bar for its current icons, and which png they're using? If I could do so, I'd be able to test if BlueTooth was on, and if it had a device connected. I want to note, this is different than using the EAAccessory, which is a different connection. In this case, I'm just trying to establish if there's a headset connected, regardless of EAAccessory state.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以采用私有 API 路线,但这很可能会让您的应用程序被拒绝。我之前曾有过一些私有 API 偷偷溜过 Apple,但在更新中被拒绝,所以请注意这一点。
CoreBluetooth
与普遍看法相反,这是可能的。您可以使用
CoreBluetooth
库。我确信,如果您的应用程序没有展示蓝牙外围设备的用途,它可能会被拒绝。但是,以下是我在使用蓝牙外围设备的应用程序之一中检测蓝牙状态的方法。请注意,这不是确定蓝牙状态的最佳方法,但可能对某些人有用。
You can go the Private API route but this will most likely get your app rejected. I have had some Private API sneak past Apple before, but rejected in an update, so be mindful of that.
CoreBluetooth
Contrary to popular belief, this is possible. You can use the
CoreBluetooth
library. I'm sure that if your app does not demonstrate a use for Bluetooth peripherals, it could be rejected.However, here is how I detect the Bluetooth state in one of my apps that does use Bluetooth peripherals. Note that this is not the best way to determine the Bluetooth state, but may work for someone.