kable icon indicating copy to clipboard operation
kable copied to clipboard

Bluetooth Permissions Modal shows prematurely

Open twyatt opened this issue 1 year ago • 6 comments

Reported internally:

Current behavior: BLE permissions pop up shows up on initial app start Expected behavior: BLE permissions pop up appears at appropriate point in pairing flow

I've tracked the issue down to CBCentralManager initialization in Kable in the CentralManager class. It seems that initialization–itself–is enough to trigger the prompt. I deleted all usages of the local cbCentralManager and did not provide a delegate in the init, so it doesn't happen when the manager is used–happens right when it's init'd. What's weird is that this isn't the behavior in iOS. I can initialize a CBManager natively without being prompted.

twyatt avatar Jun 15 '23 07:06 twyatt

Was wondering what @twyatt and @davidtaylor-juul 's thoughts are on this? Based on my findings, a reasonable solution would be to find a way to defer the initialization, but I thought there might be something I'm missing? Or maybe a better solution?

Phoenix7351 avatar Jun 23 '23 17:06 Phoenix7351

I think we should investigate further the discrepancy between natively initializing (and no prompt) vs initializing in this library and having an immediate prompt.

davidtaylor-juul avatar Jun 23 '23 18:06 davidtaylor-juul

@Phoenix7351 it'd be great to get a sample iOS app in the SensorTag sample app (it has been requested); if you have the time/bandwidth?

With iOS support in the SensorTag sample, then it would give me a nice simple repro to be able to easily investigate this issue.

twyatt avatar Jun 24 '23 21:06 twyatt

@Phoenix7351 it'd be great to get a sample iOS app in the SensorTag sample app (it has been requested); if you have the time/bandwidth?

With iOS support in the SensorTag sample, then it would give me a nice simple repro to be able to easily investigate this issue.

Agreed, but, yeah, really don't have the bandwidth for it at the moment. It might be helpful to checkout my CA-2008 branch? I did a lot in there to stub out things to eliminate them as potential causers of this issue. In that branch you can bring in/comment out the CBCentralManager to replicate the behavior. That might be helpful to start?

Phoenix7351 avatar Jun 24 '23 21:06 Phoenix7351

It just occurred to me that the issue is probably not having the iOS app side setup. I can help you with that!

Phoenix7351 avatar Jun 24 '23 21:06 Phoenix7351

https://medium.com/@adrianwitaszak/kotlin-multiplatform-mobile-bluetooth-permission-and-bluetooth-service-setting-9a697e70700

This article makes no mention of this behavior, but also instantiates CBCentralManager lazily.

Phoenix7351 avatar Jun 24 '23 22:06 Phoenix7351