Complete the code to import the PermissionsAndroid module from React Native.
import { [1] } from 'react-native';
The PermissionsAndroid module is used to handle Android permissions in React Native.
Complete the code to request camera permission using PermissionsAndroid.
const granted = await PermissionsAndroid.[1](PermissionsAndroid.PERMISSIONS.CAMERA);The request method asks the user to grant the specified permission.
Fix the error in the code to check if camera permission is granted.
const hasPermission = await PermissionsAndroid.[1](PermissionsAndroid.PERMISSIONS.CAMERA); if (hasPermission === PermissionsAndroid.RESULTS.GRANTED) { console.log('Camera permission granted'); }
The check method returns the current permission status without prompting the user.
Fill both blanks to handle permission request result correctly.
if (granted === PermissionsAndroid.RESULTS.[1]) { console.log('Permission [2]'); } else { console.log('Permission denied'); }
When permission is granted, the result is GRANTED and we log 'Permission allowed'.
Fill all three blanks to request multiple permissions and check results.
const permissions = [PermissionsAndroid.PERMISSIONS.CAMERA, PermissionsAndroid.PERMISSIONS.[1]]; const results = await PermissionsAndroid.[2](permissions); if (results[PermissionsAndroid.PERMISSIONS.CAMERA] === PermissionsAndroid.RESULTS.[3]) { console.log('Camera permission granted'); }
We request multiple permissions including CAMERA and ACCESS_FINE_LOCATION using requestMultiple. Then we check if CAMERA permission is GRANTED.