检查蓝牙状态 [英] Checking Bluetooth Status

查看:64
本文介绍了检查蓝牙状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以以编程方式检查iOS设备上是否启用了蓝牙?

Is there any way to programmatically check if Bluetooth is enabled on an iOS device?

我目前正在使用Objective-C开发本机应用程序,并使用GKSession和自定义对等选择器而不是GK Peer Picker.

I'm currently developing a native app in Objective-C and making use of GKSession and a custom peer picker rather than the GK Peer Picker.

是否可以在加载时从设置"应用程序中获取值,或者尝试通过蓝牙发送数据包以查看其是否失败?似乎GKSession甚至不允许开发人员区分数据是通过Wifi还是通过Bluetooth发送的.我不想在应用程序中启用或禁用蓝牙;我只想查看其状态.

Is it possible to grab values from the Settings application on load or attempt to send out a packet with Bluetooth to see if it failed? It seems as though GKSession doesn't even allow the developer to distinguish whether or not data is sent over Wifi or Bluetooth. I'm not looking to enable or disable Bluetooth in the app; I just want to check its status.

推荐答案

不幸的是(愚蠢?),没有办法做到.对不起.如果您想使用在问题的注释之一中链接的私有SDK方法,您当然可以,但是Apple会在提交时静态分析代码,因此不太可能在批准过程中获得它.

Unfortunately (stupidly?) there is no way to do it. Sorry. If you want to use the private SDK methods linked to in one of the comments to your question you certainly can, but Apple statically analyze code at the point of submission, so it's unlikely you'd be able to get it through the approval process.

我强烈建议您向Apple提出功能请求,以在将来的更新中要求该功能.您曾经能够使用GameKit检查蓝牙,但是当GameKit开始支持WiFi连接和蓝牙时,该功能已被删除.

I would strongly recommend you file a feature request to Apple asking for that ability in a future update. You used to be able to check for Bluetooth using GameKit, but that ability was removed when GameKit started supporting WiFi connections as well as Bluetooth.

这篇关于检查蓝牙状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆