iOS CoreBluetooth被动检查蓝牙是否启用,而不提示用户打开蓝牙 [英] iOS CoreBluetooth passively check if Bluetooth is enabled without prompting user to turn Bluetooth on

查看:851
本文介绍了iOS CoreBluetooth被动检查蓝牙是否启用,而不提示用户打开蓝牙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方案如下。我有一个已经部署的应用程序被人们使用。我正在考虑实施一些实验性的蓝牙低功耗功能,但在此之前,我想对已经开启蓝牙/留蓝牙的用户数量进行野外调查时间。所以,我想在后台检查一下,然后发送回服务器的蓝牙用户数量统计数据,而不是实际使用蓝牙通信。

The scenario is as follows. I have an already deployed app being used by people. I am considering implementing some experimental Bluetooth Low Energy features, but before I do, I want to conduct an "in the wild" survey of the number of users who already have Bluetooth turned on/leave Bluetooth on all the time. So, I would just like to check this in the background and send back to a server statistics on number of users with Bluetooth already on, without ever actually using Bluetooth communications.

我在我的应用程序中成功实例化了一个 CBCentralManager ,并且可以在实例化后立即检索蓝牙状态,并通过centralManagerDidUpdateState: 。所以这一切都很好。我遇到的问题是,如果状态为 CBCentralManagerStatePoweredOff ,则设备会显示一条警告,提示用户打开蓝牙以允许[应用程序名称]连接到附件。这是我试图避免的提示。在这个阶段,我只想调查离开蓝牙的用户数量 - 我不想使用蓝牙连接。

I have successfully instantiated a CBCentralManager in my app and can retrieve the Bluetooth status both immediately after instantiation and when the Bluetooth state updates via centralManagerDidUpdateState:. So that is all good. The problem I am having is that if the state is CBCentralManagerStatePoweredOff, then the device brings up an alert prompting the user to "Turn On Bluetooth to Allow [app name] to Connect to Accessories". It is this prompt I am trying to avoid. At this stage I just wish to survey the number of users who leave Bluetooth On - I don't wish to use the Bluetooth connection.

那么,有没有办法检查蓝牙状态而不提示用户是否打算使用蓝牙连接?

推荐答案

iOS 7在创建<$时有一个新的选项参数c $ c> CBCentralManager 将其关闭。

iOS 7 has a new options parameter in the create of CBCentralManager to turn this off.

我喜欢早期iOS的解决方案。

I'd love a solution for earlier iOS.

这篇关于iOS CoreBluetooth被动检查蓝牙是否启用,而不提示用户打开蓝牙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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