Home > Article > Web Front-end > Permissions permission application example
For mobile development, we know that permission management has been greatly upgraded after Android 6.0. Its management method similar to IOS requires manual authorization to allow the use of current permissions. Such a module also exists in RN development.
This article introduces the relevant information about the instance camera of Permissions permission application in the React Native module. I hope this article can help everyone. Friends in need can refer to it. I hope it can help everyone.
Processing method
A PermissionsAndroid module is provided in RN, which can access the permission model provided by Android M (that is, 6.0). There are some permissions written in AndroidManifest.xml that can be automatically obtained during installation. However, some "dangerous" permissions require a prompt box to pop up for the user to choose. This API is used in the latter case.
On devices lower than Android 6.0, permissions will be automatically obtained as long as they are written in AndroidManifest.xml. In this case, the check and request methods will always return true.
async function requestCameraPermission() { try { const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.CAMERA, { 'title': 'Cool Photo App Camera Permission', 'message': 'Cool Photo App needs access to your camera ' + 'so you can take awesome pictures.' } ) if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log("You can use the camera") } else { console.log("Camera permission denied") } } catch (err) { console.warn(err) } }
Related recommendations:
How to manage Users, Permissions and Groups in Django
The above is the detailed content of Permissions permission application example. For more information, please follow other related articles on the PHP Chinese website!