Created
August 27, 2019 20:42
-
-
Save EkaanshArora/bec5326ccfeb01928f59a2fa4c930b5d 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 { PermissionsAndroid } from "react-native"; | |
export default async function requestCameraAndAudioPermission() { | |
try { | |
const granted = await PermissionsAndroid.requestMultiple([ | |
PermissionsAndroid.PERMISSIONS.CAMERA, | |
PermissionsAndroid.PERMISSIONS.RECORD_AUDIO | |
]); | |
if ( | |
granted["android.permission.RECORD_AUDIO"] === | |
PermissionsAndroid.RESULTS.GRANTED && | |
granted["android.permission.CAMERA"] === | |
PermissionsAndroid.RESULTS.GRANTED | |
) { | |
console.log("You can use the cameras & mic"); | |
} else { | |
console.log("Permission denied"); | |
} | |
} catch (err) { | |
console.warn(err); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment