Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL on real ios device returns unavailable #366

Closed
fchenchen opened this issue Nov 2, 2019 · 5 comments
Labels
invalid This doesn't seem right

Comments

@fchenchen
Copy link

Thank you for such an awesome library. I tried to request PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL on a real ios device (iPhone 6s) and it returns unavailable.

The log says: Missing "bluetooth-peripheral" in "UIBackgroundModes" forces check / request result to "unavailable" status

What does this mean? Is it related to Bluetooth in background mode? My app doesn't need background mode but I should still be able to use Bluetooth.

@zoontek
Copy link
Owner

zoontek commented Nov 4, 2019

@fchenchen PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL is for requestion bluetooth peripheral permission and this particular permission needs to be able to use bluetooth in background. If you want enable this, tick this checkbox:

Screenshot 2019-11-04 at 11 48 18

If you want to ask for a bluetooth permission with no background usage, unfortunately it is not implemented yet 😕 I started working on it, it will came as PERMISSIONS.IOS.BLUETOOTH_XXX (name to be determined), but it's not easy, since the Apple documentation is at best mediocre regarding the bluetooth changes on iOS 13.

@fchenchen
Copy link
Author

fchenchen commented Nov 5, 2019

@zoontek Hi, thanks for the explanation. I did some search online about the iOS 13 changes on Bluetooth. Based on my understanding, it seems that developers have no way to manually request bluetooth permission with no background usage. We can only put the NSBluetoothAlwaysUsageDescription into info.plist and expect the system to ask for permission automatically. We do have a way to check for permission using CBManagerAuthorization.

I found some of the above information in the privacy section of the What's New in Core Bluetooth of WWDC 2019.

In my opinion, the way to handle Bluetooth permission right now is:

  1. Put NSBluetoothAlwaysUsageDescription(and NSBluetoothPeripheralUsageDescription for earlier iOS) into info.plist and expect the system to ask for permission automatically.
  2. In app, we check for bluetooth permission state using CBManagerAuthorization.
  3. If granted, everything is fine. If not granted, ask user to change it in setting.

Hope this helps.

@zoontek
Copy link
Owner

zoontek commented Nov 5, 2019

@fchenchen That's already what is done in https://github.com/react-native-community/react-native-permissions/blob/master/ios/BluetoothPeripheral/RNPermissionHandlerBluetoothPeripheral.m :) As it's for background usage, I'm looking for non-background usage documentation

@zoontek zoontek added the invalid This doesn't seem right label Nov 5, 2019
@nipuna-g
Copy link

@zoontek Would it be possible to provide the ability to check the authorizationStatus even when bluetooth-peripheral is disabled?

The use case for us would be to check if a use with an iOS 13+ device has has denied BT permissions and redirect them to the settings page.

@zoontek
Copy link
Owner

zoontek commented Nov 26, 2019

@nipuna777 Done! In the 2.0.4

@zoontek zoontek closed this as completed Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants