react native rights acquired

When the software requires the user must enter through a certain authority, this time can be App.js of compoentDidMount in (or root directory): write permissions required by the user

  

 async function requestCameraPermission() {
            try {
// 这里写的都是已进入软件就要获取的权限
const granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS ) const granted2 = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_CONTACTS, ) const granted3 = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, ) // const granted4 = await PermissionsAndroid.request( // PermissionsAndroid.PERMISSIONS.CAMERA, // ) } catch (err) { // alert("err",err); console.warn(err, '错误警告') } } if (Platform.OS === 'android') { //Calling the permission function console.log('我是安卓到', Platform.OS) requestCameraPermission(); } else { // alert('IOS device found'); }

 

 

If you are using a separate authority in other operations (special operations), as the camera's need to obtain permission to upload an avatar, you can add more code componentDidMount page of the corresponding operation, the need to change the permissions of can

Guess you like

Origin www.cnblogs.com/lude1994/p/11204090.html