React Native - dangerous permissions are automatically granted without pop-ups

I am new to responding to my own requests and checking the permission model. I added the following entry in AndroidManifes

<uses-permission android:name="android.permission.READ_CONTACTS" />

The following function is added.

async requestCameraPermission() {
  try {
    const granted = await PermissionsAndroid.request(
      PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
      {
        '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)
  }
}

And registered it in the constructor as follows

this.requestCameraPermission = this.requestCameraPermission.bind(this);

And called him

componentDidMount() {
    this.requestCameraPermission();
  }

I get permission automatically, without any pop-ups. Please let me know if I am doing something wrong or expecting something wrong.

+4
source share

Source: https://habr.com/ru/post/1679360/


All Articles