How to use the react-native-image-picker.launchCamera function in react-native-image-picker

To help you get started, we’ve selected a few react-native-image-picker 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 15826954460 / BXStage / app / pages / my / accountInfo / index.js View on Github external
Permissions.request('camera').then(res => {
        switch (res) {
          case "authorized":
            /** 调用系统拍照功能 */
            ImagePicker.launchCamera({}, response => {
              if (response.didCancel) {
                // window.console.log('User cancelled image picker');
              }
              else if (response.error) {
                // window.console.log('ImagePicker Error: ', res.error);
              }
              else if (response.customButton) {
                // window.console.log('User tapped custom button: ', response.customButton);
              }
              else {
                this.setState({
                  headPicture: response.uri
                })
              }
            })
            break;
github jessieeeee / SimpleOne / js / remark / ChangeImg.js View on Github external
openCamera() {
        // Launch Camera:
        ImagePicker.launchCamera(options, (response) => {
            // Same code as in above section!
            console.log('Response = ', response);

            if (response.didCancel) {
                console.log('User cancelled image picker');
            }
            else if (response.error) {
                console.log('ImagePicker Error: ', response.error);
            }
            else if (response.customButton) {
                console.log('User tapped custom button: ', response.customButton);
            }
            else {
                // let source = { uri: 'data:image/jpeg;base64,' + response.data }
                // console.log('source = ', source)
                this.props.route.params.response(response)
github 15826954460 / BXStage / app / pages / my / userFeedback / noFeedBack.js View on Github external
Permissions.request('camera').then(res => {
        switch (res) {
          case "authorized":
            /** 调用系统拍照功能 */
            ImagePicker.launchCamera({}, response => {
              if (response.didCancel) {
                // window.console.log('User cancelled image picker');
              }
              else if (response.error) {
                // window.console.log('ImagePicker Error: ', res.error);
              }
              else if (response.customButton) {
                // window.console.log('User tapped custom button: ', response.customButton);
              }
              else {
                if (ImageData.selectImgList.length < 4) {
                  ImageData.selectImgList.push({
                    uri: response.uri,
                    isSelect: true,
                    filename: response.uri.slice(response.uri.lastIndexOf('/') + 1)
                  })
github easemob / webim-react-native / App / Containers / MessageScreen.js View on Github external
handleCameraPicker() {
    this.setState({
      isEmoji: false
    })
    // Launch Camera:
    ImagePicker.launchCamera(options, (response) => {
      console.log('Response = ', response);

      if (response.didCancel) {
        console.log('User cancelled image picker');
      }
      else if (response.error) {
        console.log('ImagePicker Error: ', response.error);
      }
      else if (response.customButton) {
        console.log('User tapped custom button: ', response.customButton);
      }
      else {
        // You can display the image using either data...
        //const source = {uri: 'data:image/jpeg;base64,' + response.data, isStatic: true};

        // or a reference to the platform specific asset location
github RN-ONE / RNFrameWorkNew / app / overlay / ImagePickerOverlay.js View on Github external
() => {
                                                    //启动相机拍照
                                                    ImagePicker.launchCamera(AppConfig.IMAGE_PICKER_OPTIONS, (response) => {
                                                        console.log({response});
                                                        this.dismissOverlay();
                                                        if (!response.error && response.uri && this.props.callback) {
                                                            this.props.callback({
                                                                uri: response.uri,
                                                                path: response.path,
                                                                fileSize: response.fileSize,
                                                                fileName: response.fileName,
                                                                width: response.width,
                                                                height: response.height,
                                                            });
                                                        } else {
                                                            ToastAI.showShortBottom("不能打开照相机!");
                                                        }
                                                    });
                                                }, () => {
github zulip / zulip-mobile / src / compose / ComposeMenu.js View on Github external
handleCameraCapture = () => {
    const options = {
      storageOptions: {
        cameraRoll: true,
        waitUntilSaved: true,
      },
    };

    ImagePicker.launchCamera(options, this.handleImagePickerResponse);
  };
github mattermost / mattermost-mobile / app / components / post_textbox / components / cameraButton.js View on Github external
},
            permissionDenied: {
                title,
                text,
                reTryTitle: formatMessage({
                    id: 'mobile.permission_denied_retry',
                    defaultMessage: 'Settings',
                }),
                okTitle: formatMessage({id: 'mobile.permission_denied_dismiss', defaultMessage: 'Don\'t Allow'}),
            },
        };

        const hasCameraPermission = await this.hasPhotoPermission(source, mediaType);

        if (hasCameraPermission) {
            ImagePicker.launchCamera(options, (response) => {
                if (response.error || response.didCancel) {
                    return;
                }

                this.uploadFiles([response]);
            });
        }
    };
github keybase / client / shared / chat / conversation / input-area / normal / platform-input.native.js View on Github external
if (response.didCancel || !this.props.conversationIDKey) {
        return
      }
      if (response.error) {
        this.props.onFilePickerError(new Error(response.error))
        return
      }
      const filename = isIOS ? response.uri.replace('file://', '') : response.path
      if (filename) {
        this.props.onAttach([filename])
      }
    }

    switch (location) {
      case 'camera':
        launchCamera({mediaType, permissionDenied, takePhotoButtonTitle, title}, handleSelection)
        break
      case 'library':
        launchImageLibrary({mediaType, permissionDenied, takePhotoButtonTitle, title}, handleSelection)
        break
    }
  }
github mattermost / mattermost-mobile / app / components / attachment_button / index.js View on Github external
},
            permissionDenied: {
                title,
                text,
                reTryTitle: formatMessage({
                    id: 'mobile.permission_denied_retry',
                    defaultMessage: 'Settings',
                }),
                okTitle: formatMessage({id: 'mobile.permission_denied_dismiss', defaultMessage: 'Don\'t Allow'}),
            },
        };

        const hasCameraPermission = await this.hasPhotoPermission(source, mediaType);

        if (hasCameraPermission) {
            ImagePicker.launchCamera(options, (response) => {
                if (response.error || response.didCancel) {
                    return;
                }

                this.uploadFiles([response]);
            });
        }
    };
github iyegoroff / react-native-image-filter-kit / examples / ImageExtraction / src / App.tsx View on Github external
new Promise((resolve, reject: (reason: Error) => void) => {
    ImagePicker.launchCamera(
      {},
      ({ didCancel, error, uri }: ImagePickerResponse) => {
        if (didCancel) {
          reject(new Error('cancelled'))

        } else if (error) {
          reject(new Error(error))

        } else {
          resolve(uri)
        }
      }
    )
  })
)

react-native-image-picker

A React Native module that allows you to use native UI to select media from the device library or directly from the camera

MIT
Latest version published 8 months ago

Package Health Score

88 / 100
Full package analysis