expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
445 stars 95 forks source link

BLE works without asking user for permission? #16

Closed dbalatoni13 closed 3 years ago

dbalatoni13 commented 3 years ago

I'm testing the BLE config and I don't get a prompt that asks for Bluetooth permissions and everything works fine despite that. Why is that? Does it have the same behaviour in production builds?

How can I/should I actively prompt the user to accept the permissions?

dbalatoni13 commented 3 years ago

I figured out that only the location permission needs to be actually prompted and I found the guides for that.

petrusek commented 2 years ago

@kabiskac is it required to add some (own) code to request the location permissions or does expo / react-native-ble-plx handle the request when it is required? For iOS it requested the bluetooth permission at the moment I started using it ... without any extra code. For Android it doesn't request anything and it fails with "no permission".

Could you please post a link to the guide you found for that? Is it possible to request only bluetooth permission with a fallback to location on older SDKs? Or is location still required for all (new) Androids?

EvanBacon commented 2 years ago

@petrusek this plugin simply configures the native static permissions, you may find more useful API resources in the react-native-ble-plx repo.

petrusek commented 2 years ago

Thank you @EvanBacon ... I will experiment with some code I found here https://github.com/PolideaPlayground/SensorTag/blob/master/src/Saga.js#L127 (linked from the ble-plx repo). I just wasn't sure if there is no documentation for it.

Btw. starting from API level 31 it seems it won't be necessary to request location permissions, so it would be great if the plugin would be able to also add this (maybe based on some params):

    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
                     android:usesPermissionFlags="neverForLocation" />

I guess also my runtime code requesting the permission will need to be aware of the API level (Platform.Version) to request the correct permission - fine location or scan (https://reactnative.dev/docs/permissionsandroid#permissions-that-require-prompting-the-user).