chipweinberger / flutter_blue_plus

Flutter plugin for connecting and communicationg with Bluetooth Low Energy devices, on Android, iOS, macOS
Other
748 stars 455 forks source link

Bluetooth permission ask on start up in ios #388

Closed divyaEncodework closed 1 year ago

divyaEncodework commented 1 year ago

@boskokg when I start my application in ios Bluetooth permission is asked on startup but I need Bluetooth on only one screen how can I manage it? if anyone has a solution please update me thank you

chipweinberger commented 1 year ago

just make sure not to call any FlutterBluePlus code until needed and it should work i think.

divyaEncodework commented 1 year ago

hii @chipweinberger I am not using anything of flutter blue plus on the splash screen or login screen still permission dialogue is showing on startup

chipweinberger commented 1 year ago

not sure. try looking at the device logs using a Macbook and opening Console.app.

let me know the fix.

divyaEncodework commented 1 year ago

i cant find any Bluetooth services in logs and I am not using it in start up

chipweinberger commented 1 year ago

perhaps you permissions plist has issues? try removing the bluetooth permission and see what happens.

divyaEncodework commented 1 year ago

but I need Bluetooth permissions on another screen

chipweinberger commented 1 year ago

I know. But temporarily remove the permission to help troubleshoot. Does it still happen?

divyaEncodework commented 1 year ago

if I remove permission then my app crashes on my iPhone with the message that app is trying to access data without permission

chipweinberger commented 1 year ago

let me know if you fix it.

This might happen when we instantiate the CBCentralManager.

Try searching the code and try commenting those lines out and seeing what happens.

chipweinberger commented 1 year ago

did you figure it out?

divyaEncodework commented 1 year ago

no, precisely that's because of CBCentralManager. but I don't know which file I have to change.

chipweinberger commented 1 year ago

The CBCentralManager is only invoked if you interact with FlutterBluePlus.

If you see any logs like:

2023-07-24 21:29:14.845 macos[72103:5766776] [FBP-iOS] handleMethodCall: XXXXXXXX

Then the problem is in your code. You should not be calling any FlutterBluePlus functions at all.

divyaEncodework commented 1 year ago

no, I am not using any flutterBluePlus functions and not receiving logs like this. it asks permission in my login screen and I am not even importing Flutterblueplus

chipweinberger commented 1 year ago

Have you tried commenting out all of your flutterBluePlus code?

divyaEncodework commented 1 year ago

I can't do this it's a live project we need it for device configurations.

chipweinberger commented 1 year ago

? I am not asking for you to save the changes.

Just comment out the code, click "run", and see what happens.

divyaEncodework commented 1 year ago

I comment out all the code and run the application Bluetooth permission dialogue still occurs.

divyaEncodework commented 1 year ago

ok, I found that this dialogue is not because of your plugin. thank you.

chipweinberger commented 1 year ago

glad you figured it out!