react-native-ble-manager icon indicating copy to clipboard operation
react-native-ble-manager copied to clipboard

Bluetooth permission on iOS is asked on App launch

Open shettayyy opened this issue 1 year ago • 9 comments

Describe the bug

Bluetooth permission dialog/pop-up opens up as soon as I launch the app. I would prefer the users to see it on the screen where they are using this library rather than showing it on the app launch

To Reproduce I am using the Expo development build

  1. Install the package
  2. Create an expo development build
  3. Open the app
  4. You should see the permission dialogue pop-up

Expected behaviour Show the permission dialog where the manager is used/started.

Smartphone (please complete the following information):

  • Device: iPhone 14 Pro Max
  • OS: iOS 17.4.1
  • react-native-ble-manager version: 11.5.3
  • react-native version: 0.73.6

shettayyy avatar May 09 '24 11:05 shettayyy

I guess that's the default behavior for iOS for any device using bluetooth. You can customize the message on the infoplist.

lucaswitch avatar May 10 '24 13:05 lucaswitch

@lucaswitch So, there isn't a way to show this dialog where this package is used? There is a possibility of users dismissing the dialog mistakenly. I would prefer to show my dialog component before showing the system dialog for Bluetooth permissions. But, at present, I am not sure if it's possible considering the default behaviour for iOS.

shettayyy avatar May 10 '24 13:05 shettayyy

@lucaswitch https://stackoverflow.com/questions/29456654/bluetooth-le-ask-permission

From this post, it seems like it is possible to ask permission when we actually would like to use the feature.

shettayyy avatar May 10 '24 13:05 shettayyy

Got it. For doing that is pretty straightforward. Watch the bluetooth adapter state and make that dialog. If the state is not but "on" then user has to get that dialog. Hope it helps!

lucaswitch avatar May 12 '24 00:05 lucaswitch

@lucaswitch I don't think my app gets the opportunity to check for the state. The pop-up appears as soon as the app opens. I have not written any code to start the Ble manager at the app launch. It appears without calling the Blemanager.start()

So, install the package on Expo (Expo development build) and start the app on an actual device. It asks for Bluetooth permissions as soon as we open the app. I wanna ask it on the page where the Bluetooth feature is being used.

shettayyy avatar May 14 '24 11:05 shettayyy

@lucaswitch I don't think my app gets the opportunity to check for the state. The pop-up appears as soon as the app opens. I have not written any code to start the Ble manager at the app launch. It appears without calling the Blemanager.start()

So, install the package on Expo (Expo development build) and start the app on an actual device. It asks for Bluetooth permissions as soon as we open the app. I wanna ask it on the page where the Bluetooth feature is being used.

Not sure quite sure, but i guess that permission you're seeing is prompted by the operating system itself when you add the bluetooth into infoplist.

lucaswitch avatar May 17 '24 14:05 lucaswitch

I have a related issue in Android. When launching the app, it asks for permission, and I grant it, but the scan is not working. I checked the phone settings, and the permissions are granted. When I toggle the permission off and then on again from my physical device's settings, the scan works perfectly. So, the permission needs to be granted from the physical device settings.

Device: MI 11X react-native-ble-manager version: 11.5.3 react-native version:0.74.1

jeslo avatar May 22 '24 06:05 jeslo

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

marcosinigaglia avatar Aug 21 '24 02:08 marcosinigaglia

I think this is something to look into as there is quite a possibility of users mistakenly skipping the prompt shown as soon as the app is opened. I don't think it should be closed unless someone reproduces this issue and the prompt is not shown at the beginning in iOS. I humbly request the ability to ask for Bluetooth permission when we use it as opposed to asking when the app opens.

shettayyy avatar Aug 21 '24 07:08 shettayyy

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

marcosinigaglia avatar Nov 20 '24 02:11 marcosinigaglia