Last active
July 5, 2020 11:27
-
-
Save uddish/1f508e04c5050bcddd8ac8ce9bc42f2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Platform, Alert, Linking } from 'react-native'; | |
import { checkMultiplePermissions } from '../../services/permissions';` | |
// Requesting for the Microphone permission | |
static async checkForPermissions() { | |
const permissions = | |
Platform.OS === 'ios' | |
? [PERMISSIONS.IOS.MICROPHONE] | |
: [PERMISSIONS.ANDROID.RECORD_AUDIO]; | |
// Call our permission service and check for permissions | |
const isPermissionGranted = await checkMultiplePermissions(permissions); | |
if (!isPermissionGranted) { | |
// Show an alert in case permission was not granted | |
Alert.alert( | |
'Permission Request', | |
'Please allow permission to access the Microphone.', | |
[ | |
{ | |
text: 'Go to Settings', | |
onPress: () => { | |
Linking.openSettings(); | |
}, | |
}, | |
{ | |
text: 'Cancel', | |
style: 'cancel', | |
}, | |
], | |
{ cancelable: false }, | |
); | |
} | |
return isPermissionGranted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment