Code Monkey home page Code Monkey logo

Comments (6)

TirathBhuva avatar TirathBhuva commented on August 26, 2024

Hey azzi907,
Looks like your app does not have camera permission, can you check whether you have given camera permission?

from cometchat-sample-app-react-native.

azzi907 avatar azzi907 commented on August 26, 2024

@TirathBhuva camera permission are given already i checked already

from cometchat-sample-app-react-native.

azzi907 avatar azzi907 commented on August 26, 2024

Screenshot 2021-04-30 at 9 45 14 PM

See info plist file, Camera permission is given and it is being used in other part of application as well

from cometchat-sample-app-react-native.

azzi907 avatar azzi907 commented on August 26, 2024

@TirathBhuva any update on this?

from cometchat-sample-app-react-native.

TirathBhuva avatar TirathBhuva commented on August 26, 2024

Hey @azzi907 ,
We were able to reproduce this issue on our end we will fix this in the next release.
For now, you can use this patch.
In the ComposerActions.js replace the takePhoto function with the below function. This should solve the issue.

takePhoto = async () => {
    try {
      let granted = null;
      if (Platform.OS === 'android') {
        granted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.CAMERA,
          {
            title: 'CometChat Camera Permission',
            message: 'CometChat needs access to your camera ',
            buttonNegative: 'Cancel',
            buttonPositive: 'OK',
          },
        );
      }

      if (
        Platform.OS === 'ios' ||
        granted === PermissionsAndroid.RESULTS.GRANTED
      ) {
        launchCamera(
          {
            includeBase64: false,
          },
          (response) => {
            this.sheetRef.current.snapTo(1);
            this.props.close();
            if (response.didCancel) {
              return null;
            }
            let type = null;
            let name = null;
            if (Platform.OS === 'ios' && response.fileName !== undefined) {
              name = response.fileName;
            } else {
              type = response.type;
              name = 'Camera_001.jpeg';
            }
            const file = {
              name: Platform.OS === 'android' ? response.fileName : name,
              type: response.type,
              uri:
                Platform.OS === 'android'
                  ? response.uri
                  : response.uri.replace('file://', ''),
            };
            this.props.sendMediaMessage(file, CometChat.MESSAGE_TYPE.IMAGE);
          },
        );
      }
    } catch (err) {
      this.sheetRef.current.snapTo(1);
      this.props.close();
    }
  };

from cometchat-sample-app-react-native.

azzi907 avatar azzi907 commented on August 26, 2024

@TirathBhuva thanks

from cometchat-sample-app-react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.