mattermost-mobile/app/products/calls/actions/permissions.ts
Daniel Espino García 9d1030a445
Push react native to 0.73.6 (#7863)
* Bump react native to 0.73.6

* iOS changes

* Fix gallery

* Fix test

* Add missing patch

* Unify react native navigation patch

* Update the rest of libraries

* iOS updates

* Update mattermost libraries

* Fix tests and final bumps

* iOS podfile update

* Update android locks

* Revert webrtc update because it was messing with the tests

* Update podfile for webrtc
2024-04-22 12:44:39 +02:00

48 lines
1.5 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Platform} from 'react-native';
import Permissions from 'react-native-permissions';
export const hasBluetoothPermission = async () => {
const bluetooth = Platform.select({
ios: Permissions.PERMISSIONS.IOS.BLUETOOTH,
default: Permissions.PERMISSIONS.ANDROID.BLUETOOTH_CONNECT,
});
const hasBluetooth = await Permissions.check(bluetooth);
switch (hasBluetooth) {
case Permissions.RESULTS.DENIED:
case Permissions.RESULTS.UNAVAILABLE: {
const permissionRequest = await Permissions.request(bluetooth);
return permissionRequest === Permissions.RESULTS.GRANTED;
}
case Permissions.RESULTS.BLOCKED:
return false;
default:
return true;
}
};
export const hasMicrophonePermission = async () => {
const microphone = Platform.select({
ios: Permissions.PERMISSIONS.IOS.MICROPHONE,
default: Permissions.PERMISSIONS.ANDROID.RECORD_AUDIO,
});
const hasMicrophone = await Permissions.check(microphone);
switch (hasMicrophone) {
case Permissions.RESULTS.DENIED:
case Permissions.RESULTS.UNAVAILABLE: {
const permissionRequest = await Permissions.request(microphone);
return permissionRequest === Permissions.RESULTS.GRANTED;
}
case Permissions.RESULTS.BLOCKED:
return false;
default:
return true;
}
};