mirror of https://github.com/msgbyte/tailchat
feat(mobile): add webrtc permission grant and allow webrtc service work correct
parent
5d39f92f3c
commit
3de7fe2c69
@ -0,0 +1,22 @@
|
|||||||
|
import { request, check, PERMISSIONS } from 'react-native-permissions';
|
||||||
|
import { Platform } from 'react-native';
|
||||||
|
|
||||||
|
export async function ensureWebRTCPermission() {
|
||||||
|
const cameraPermission =
|
||||||
|
Platform.OS === 'ios' ? PERMISSIONS.IOS.CAMERA : PERMISSIONS.ANDROID.CAMERA;
|
||||||
|
const microphonePermission =
|
||||||
|
Platform.OS === 'ios'
|
||||||
|
? PERMISSIONS.IOS.MICROPHONE
|
||||||
|
: PERMISSIONS.ANDROID.RECORD_AUDIO;
|
||||||
|
|
||||||
|
const [cameraPermissionStatus, microphonePermissionStatus] =
|
||||||
|
await Promise.all([check(cameraPermission), check(microphonePermission)]);
|
||||||
|
|
||||||
|
if (microphonePermissionStatus !== 'granted') {
|
||||||
|
await request(microphonePermission);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cameraPermissionStatus !== 'granted') {
|
||||||
|
await request(cameraPermission);
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
export * from '../../../packages/types/index';
|
export * from '../../../packages/types';
|
||||||
|
Loading…
Reference in New Issue