iOS:无法让蓝牙管理器工作

发布于 2024-10-18 14:26:13 字数 547 浏览 8 评论 0原文

警告:我知道私有框架不会在 App Store 中运行。

我尝试使用 BluetoothManager 框架来让我 1) 检查设备上是否启用了蓝牙,以及 2)未开启,请开启。

我可以按照此处找到的说明成功加载BluetoothManager,但是一旦我这样做了,BluetoothManager 似乎就没有做任何事情。

即使蓝牙已启用,调用启用始终返回“否”。调用 setEnabled 永远不会改变其状态。绝对,我尝试过的所有其他 BluetoothManager 调用总是返回 NO、nil、零元素数组等。简而言之,返回的 BluetoothManager 似乎完全中性了。 (我正在运行我的 4.2.1 iPhone,而不是模拟器。)

我看过那些声称已经可以正常工作的人的帖子,但我还没有得到他们的回复。任何人都可以阐明为什么这可能行不通吗?

非常感谢。

Caveat: I know that private frameworks won't fly in the App Store.

I'm trying to use the BluetoothManager framework to let me 1) check if Bluetooth is enabled on a device, and 2) if not on, turn it on.

I can successfully load BluetoothManager per the instructions found here, but once I've done so, BluetoothManager just doesn't seem to do anything.

Calling enabled always returns NO, even when Bluetooth is enabled. Calling setEnabled never changes its state. Absolutely every other BluetoothManager call I've tried always returns NO, nil, zero-element arrays, etc. In short, the BluetoothManager that gets returned seems totally neutered. (I'm running off my 4.2.1 iPhone, not the simulator.)

I've seen posts from people who claim to have gotten this working, yet I haven't been able to get a response from them. Can anyone shed light on why this might not be working?

Thanks very much.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╰つ倒转 2024-10-25 14:26:13

BluetoothManager 启动并连接到 BTServer 需要一秒钟的时间。我只是快速调用了共享实例 - [BluetoothManager sharedInstance]; - 以强制其初始化。一旦完成初始化,它将发布一个BluetoothAvailabilityChangedNotification。我只是听一下并在通知回调中尝试 [[BluetoothManager sharedInstance] setEnabled:YES];

仅供参考,BluetoothAvailabilityChangedNotification 的 NSNotification 中包含的对象是一个布尔值,因此您应该能够检查它以确保蓝牙确实可用。

It takes a second for the BluetoothManager to startup and attach to the BTServer. I just did a quick call to the shared instance - [BluetoothManager sharedInstance]; - to force it to init. Once it's finished init it will post a BluetoothAvailabilityChangedNotification. I'd just listen for that and try [[BluetoothManager sharedInstance] setEnabled:YES]; in the notification callback.

FYI, the object included in the NSNotification for BluetoothAvailabilityChangedNotification is a boolean, so you should be able to check that to make sure that Bluetooth is really available.

眼眸 2024-10-25 14:26:13

那是因为IPC。 BluetoothManager 通过 sendMsg 等进行通信。例如,使用 NSTimer 来查询 BluetoothManager SharedInstance,以便您的程序有时间接收和处理消息。

That's because of IPC. BluetoothManager communicates via sendMsg et el. Use for example NSTimer to query BluetoothManager sharedInstance so your program has time to receive and process messages.

凉风有信 2024-10-25 14:26:13

Github 上有一个名为 BeeTee 的 演示项目,用于演示私有框架 BluetoothManager。

There is a demo project on Github called BeeTee for demonstrating the private framework BluetoothManager.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文