简体   繁体   中英

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?

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).

Do I have to simply dealloc the centralManager and create a new instance without restoration identifier?

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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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