Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(props) {
super(props);
this.peripherals = [];
BleManager.enableBluetooth()
.then(() => {
console.log('Bluetooth is already enabled');
})
.catch((error) => {
Alert.alert('Enable bluetooth', 'You need to enable bluetooth to use this app.');
});
BleManager.start({showAlert: false})
.then(() => {
console.log('Module initialized');
});
if (Platform.OS === 'android' && Platform.Version >= 23) {
PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
if(!result){
PermissionsAndroid.requestPermission(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION).then((result) => {
enableBluetooth() {
BleManager.enableBluetooth()
.then(() => {
console.log('The bluetooh is already enabled or the user confirm');
})
.catch((error) => {
console.log('The user refuse to enable bluetooth');
});
}
enableBluetooth() {
BleManager.enableBluetooth()
.then(() => {
console.log('The bluetooh is already enabled or the user confirm');
})
.catch((error) => {
console.log('The user refuse to enable bluetooth');
});
}