Home > Web Front-end > JS Tutorial > body text

Permissions permission application example

小云云
Release: 2018-02-01 09:24:36
Original
1817 people have browsed it

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)
 }
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template