import { AndroidPermissions } from '@ionic-native/android-permissions';
const permissions =
{
//Working
requestCameraPermission() {
if (Capacitor.isNativePlatform()) {
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.CAMERA).then(
result => {
if (result.hasPermission) {
//alert('you already have this permission')
alert('camera permission already granted');
} else {
//alert('please implement permission request')
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.CAMERA);
}
}
)
}
else {
console.log('Capacitor not detected, this button will do nothing
}
},
//NOT WORKING | App thinks request is already granted
requestBluetooth() {
if (Capacitor.isNativePlatform()) {
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.BLUETOOTH).then(
result => {
if (result.hasPermission) {
alert('bluetooth permission already granted');
} else {
alert('bluetooth permission not granted');
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.BLUETOOTH);
}
}
)
}
else {
console.log('Capacitor not detected, this button will do nothing
}
},
//NOT WORKING | App thinks request is already granted
requestBluetoothAdmin() {
if (Capacitor.isNativePlatform()) {
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.BLUETOOTH_ADMIN).then(
result => {
if (result.hasPermission) {
alert('bluetooth permission already granted');
} else {
alert('bluetooth permission not granted');
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.BLUETOOTH_ADMIN);
}
}
)
}
else {
console.log('Capacitor not detected, this button will do nothing
}
},
//NOT WORKING | permission not granted | request not working
requestBluetoothConnect() {
if (Capacitor.isNativePlatform()) {
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.BLUETOOTH_CONNECT).then(
result => {
if (result.hasPermission) {
alert('bluetooth permission already granted');
} else {
alert('bluetooth permission not granted');
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.BLUETOOTH_CONNECT);
}
}
)
}
else {
console.log('Capacitor not detected, this button will do nothing
}
},
//NOTWORKING | permission not granted | request not working
requestBluetoothScan() {
if (Capacitor.isNativePlatform()) {
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.BLUETOOTH_SCAN).then(
result => {
if (result.hasPermission) {
alert('bluetooth permission already granted');
} else {
alert('bluetooth permission not granted');
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.BLUETOOTH_SCAN);
}
}
)
}
else {
console.log('Capacitor not detected, this button will do nothing
}
},
//Working
requestFineLocation() {
if (Capacitor.isNativePlatform()) {
AndroidPermissions.checkPermission(AndroidPermissions.PERMISSION.ACCESS_FINE_LOCATION).then(
result => {
if (result.hasPermission) {
alert('fine location permission already granted');
} else {
alert('fine location permission not granted');
AndroidPermissions.requestPermission(AndroidPermissions.PERMISSION.ACCESS_FINE_LOCATION);
}
}
)
}
else {
console.log('Capacitor not detected, this button will do nothing
}
}
}
export default permissions;
< /code>
android manifest.xml Файл, показывающий, что я правильно объявил разрешения, которые я пытаюсь использовать < /p>
Подробнее здесь: https://stackoverflow.com/questions/701 ... -capacitor
Мобильная версия