Does not prompt the user for request when demanding the bluetooth permission on iphone 6.
iOs version 12.4.2
When requesting the permissions with everything setup in .plist and pods it keeps returning 'denied' even tho the user has never seen bluetooth prompt.
The same configuration works fine with newer iOS version.
Also tested on fresh app, does not work with iOS 12 on version 2, but does on version 1
We also chained multiple promises to ask for permissions, but always get "denied"
react-native-permissions version : 2.2.0
react-native info output:
System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 253.81 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.6.0 - ~/.nvm/versions/node/v12.6.0/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.9.0 - ~/.nvm/versions/node/v12.6.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.6, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
Android SDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 11.6/11E708 - /usr/bin/xcodebuild
Languages:
Java: 11.0.2 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: Not Found
react-native: Not Found
npmGlobalPackages:
*react-native*: Not Found
Library version: x.x.x
PermissionRequest(
PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL,
)
Describe what you expected to happen:
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {
PERMISSIONS,
request as PermissionRequest,
} from 'react-native-permissions';
PermissionRequest(
PERMISSIONS.IOS.BLUETOOTH_PERIPHERAL,
)
.then(console.log)
export default function App() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
Hi. Did you check the "Bluetooth peripheral" capability in Xcode too?
Hi,
Yes, these ones are checked :
@KristenGarnier Could you try 2.1.4 to check if the version 2.1.5 did not introduce a regression?
@zoontek We were using version 2.1.0 before, and it was not working either
But i will try on version 2.1.4 next time, see if it works there
I'm having exactly the same issue with version 2.1.2 and iOS version 12.4.8. The bluetooth peripheral capability is ticked in Xcode.
I've done some more research, it looks like this is not a bug in react-native-permissions. The problem is explained here: https://github.com/react-native-community/react-native-permissions/issues/458#issuecomment-623077980
bluetooth-central background modebluetooth-peripheral background mode@KristenGarnier you said you had Uses Bluetooth LE accessories checked, but didn't mention Acts as a Bluetooth LE accessory. This is probably the source of the problem.
You can see the source code for that react-native-permissions is doing under the covers here:
https://github.com/react-native-community/react-native-permissions/blob/e9193c93c3c1f5e7d285bea3570f974481ee5956/ios/BluetoothPeripheral/RNPermissionHandlerBluetoothPeripheral.m#L32-L55
For iOS 13, it uses CBManager which correctly requests permission to use Bluetooth. For iOS<=12, this general Bluetooth permission did not exist, however permission for the iPhone to act as a Bluetooth peripheral did exist. However, it is likely that your application is trying to act as a central, not a peripheral (hence why you would tick Uses Bluetooth LE accessories but leave Acts as a Bluetooth LE accessory unticked. So react-native-permissions requests permission to act as a bluetooth peripheral for iOS<=12, which will automatically be denied if Acts as a Bluetooth LE accessory is unchecked.
I would recommend the solution given in https://github.com/react-native-community/react-native-permissions/issues/458#issuecomment-622564566. If you only want to act as a central on iOS<=12, there is no need to request any bluetooth permissions at all.
Edit: If react-native-permissions wanted to reduce this confusion, perhaps there could be a PERMISSIONS.IOS.BLUETOOTH_CENTRAL which does the same as BLUETOOTH_PERIPHERAL on iOS 13, but always returns GRANTED on iOS<=12
Hi @bwindsor, thanks for your explaination !
I came here to say just what you said, that you do not need to request permission in iOS 12 or lower :)
That was quite confusing on our part and felt a bit like a "hack", I guess we are used to asking for permissions everywhere (which is a good thing IMO)
Still, there is maybe a need for this to be documented somewhere, so people don't end up confused as we were discovering this weird behaviour.
If someone can point me to where it would make sens to belong, i would be happy to document this findings 😄
Again thanks for your time !
Have a nice day
If react-native-permissions wanted to reduce this confusion, perhaps there could be a PERMISSIONS.IOS.BLUETOOTH_CENTRAL which does the same as BLUETOOTH_PERIPHERAL on iOS 13, but always returns GRANTED on iOS<=12
That's probably the best solution. I'll try to write a permission handler for it soon.
@bwindsor thank you for your exporering !
same problem was
Most helpful comment
I've done some more research, it looks like this is not a bug in react-native-permissions. The problem is explained here: https://github.com/react-native-community/react-native-permissions/issues/458#issuecomment-623077980
bluetooth-centralbackground modebluetooth-peripheralbackground mode@KristenGarnier you said you had Uses Bluetooth LE accessories checked, but didn't mention Acts as a Bluetooth LE accessory. This is probably the source of the problem.
You can see the source code for that
react-native-permissionsis doing under the covers here:https://github.com/react-native-community/react-native-permissions/blob/e9193c93c3c1f5e7d285bea3570f974481ee5956/ios/BluetoothPeripheral/RNPermissionHandlerBluetoothPeripheral.m#L32-L55
For iOS 13, it uses
CBManagerwhich correctly requests permission to use Bluetooth. For iOS<=12, this general Bluetooth permission did not exist, however permission for the iPhone to act as a Bluetooth peripheral did exist. However, it is likely that your application is trying to act as a central, not a peripheral (hence why you would tick Uses Bluetooth LE accessories but leave Acts as a Bluetooth LE accessory unticked. Soreact-native-permissionsrequests permission to act as a bluetooth peripheral for iOS<=12, which will automatically be denied if Acts as a Bluetooth LE accessory is unchecked.I would recommend the solution given in https://github.com/react-native-community/react-native-permissions/issues/458#issuecomment-622564566. If you only want to act as a central on iOS<=12, there is no need to request any bluetooth permissions at all.
Edit: If
react-native-permissionswanted to reduce this confusion, perhaps there could be aPERMISSIONS.IOS.BLUETOOTH_CENTRALwhich does the same asBLUETOOTH_PERIPHERALon iOS 13, but always returnsGRANTEDon iOS<=12