How to use the react-native-camera.checkDeviceAuthorizationStatus function in react-native-camera

To help you get started, we’ve selected a few react-native-camera examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shoutem / extensions / shoutem.camera / app / components / QRCodeScanner.js View on Github external
constructor(props) {
    super(props);

    this.updateIsAuthorized = this.updateIsAuthorized.bind(this);

    let isAuthorized = true;
    if (Platform.OS === 'ios') {
      // Asks for permissions if not defined, returns choice otherwise
      isAuthorized = undefined;
      Camera.checkDeviceAuthorizationStatus().then(this.updateIsAuthorized);
    }

    this.state = { isAuthorized };

    this.onQRCodeScanned = _.debounce(props.onQRCodeScanned, 1000, { leading: true, trailing: false });
  }
github MiEcosystem / miot-plugin-sdk / projects / com.xiaomi.demo / Main / ThirdPartDemo / ReactNativeCameraDemo.js View on Github external
takePicture = async function () {
        if (Host.isIOS) {
            if (!await Camera.checkDeviceAuthorizationStatus()) {
                alert('相机权限未开启')
                return
            }
        }

        if (Host.isAndroid) {
            if (!await PermissionsAndroid.check(PermissionsAndroid.PERMISSIONS.CAMERA)) {
                alert('相机权限未开启')
                return
            } else {
                console.log('相机权限已开启');
            }
        }
        if (this.camera) {
            const options = { quality: 0.5, base64: true };
            const data = await this.camera.takePictureAsync(options);
github febobo / react-native-redux-FeInn / src / page / Login.js View on Github external
login (){
    const { navigator } = this.props;
    if(Platform.OS == 'ios'){
      Camera.checkDeviceAuthorizationStatus().then( (isAuth) =>{
        if(isAuth){
          navigator.push({
            component : QrCode
          })
        }else{
          actions.toast('请在设置中开启Noder对相机的访问')
        }
      }).catch( (err) =>{
        actions.toast('获取相机访问权错误');
      })
    }else{
      navigator.push({
        component : QrCode
      })
    }
github Skjutsgruppen / skjutsgruppen-reactnative / app / components / experience / camera.js View on Github external
grantCameraPermission = async () => {
    try {
      if (Platform === 'ios' || Platform.OS === 'ios') {
        const permission = await Camera.checkDeviceAuthorizationStatus();
        this.setState({ loading: false, permissionDenied: !permission });
      } else {
        const cameraGranted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.CAMERA);
        const interalStorageGranted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE);
        const externalStorageGranted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE);
        if (cameraGranted === PermissionsAndroid.RESULTS.GRANTED
          && interalStorageGranted === PermissionsAndroid.RESULTS.GRANTED
          && externalStorageGranted === PermissionsAndroid.RESULTS.GRANTED) {
          this.setState({ loading: false, permissionDenied: false });
        } else {
          this.setState({ loading: false, permissionDenied: true });
        }
      }