简体   繁体   English

有什么方法可以选择退出核心蓝牙状态恢复?

[英]Is there any way to opt out of Core Bluetooth state restoration?

Do someone know how to opt out of CB state restoration once the CBCentralManager has already been instantiated with a restoration identifier? 一旦已经用恢复标识符实例化了CBCentralManager,有人知道如何退出CB状态恢复吗?

Basically I want to turn CB state restoration off again depending on some conditions (= I don't want to use state restoration all the time). 基本上,我想根据某些条件再次关闭CB状态恢复(=我不想一直使用状态恢复)。

Do I have to simply dealloc the centralManager and create a new instance without restoration identifier? 我是否必须简单地取消分配centralManager并创建没有恢复标识符的新实例?

You are absolutely correct. 你是绝对正确的。 The application itself opts in when you specify in the info.plist file that you'd like the app to have the ability to have bluetooth functionality in the background. 当您在info.plist文件中指定希望该应用程序能够在后台具有蓝牙功能时,该应用程序本身就会选择加入。 The user then ultimately gets to decide whether your app can work on the background via the uialertview that pops up on first launch or in the device's settings. 然后,用户最终可以通过首次启动时或在设备设置中弹出的uialertview来决定您的应用是否可以在后台运行。 You then decide whether each central manager (and/or peripheral manager) you instantiate will opt in or not. 然后,您决定实例化的每个中央管理器(和/或外围设备管理器)是否会选择加入。 You can even have one central manager opt in and another one not opt in and have them active at the same time. 您甚至可以选择一个中央管理器选择加入,而另一个不选择加入,同时激活它们。

I currently do this in my app and it works really well. 我目前在我的应用程序中执行此操作,并且效果很好。 One central manager is opted in and is always scanning. 一位中央经理被选中并一直在扫描。 When I need it, I instantiate a second central manager that does not opt in and is only active for a few seconds. 当我需要它时,我实例化了第二个中央管理器,该中央管理器不选择加入,并且仅在几秒钟内处于活动状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM