state = {
scanning: false,
}
initDevInfo = ()=>{
BleManager.enableBluetooth()
.then(() => {
console.log('开启成功');
})
.catch((error) => {
console.log('The user refuse to enable bluetooth');
});
BleManager.start({ showAlert: false }).then(() => {
console.log('开始了')
});
this.onCheckLocation();
this.handlerDiscover = bleManagerEmitter.addListener('BleManagerDiscoverPeripheral', this.handleDiscoverPeripheral);
this.handlerStop = bleManagerEmitter.addListener('BleManagerStopScan', this.handleStopScan);
}
onCheckLocation =()=>{
if(Platform.OS === 'ios'){
return false;
}
const granted =PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION)
granted.then((data)=>{
if(!data){
this.requestLocationPermission()
}
}).catch((err)=>{
console.log('err---------',err.toString())
})
}
async requestLocationPermission() {
try {
const