How to use the expo-image-picker.launchCameraAsync function in expo-image-picker

To help you get started, we’ve selected a few expo-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 SCasarotto / casarotto-chat / src / pages / Main / Main.js View on Github external
.then((response) => {
				const { status, expires, permissions } = response
				if (status === 'granted') {
					ImagePicker.launchCameraAsync({
						// mediaTypes: 'All',
						base64: true,
						quality: 1,
					})
						.then((response) => {
							if (!response.cancelled) {
								const { user, sendImage } = this.props
								//TODO: Check if it is a video and store video
								const data = { uri: response.uri, user }
								sendImage(data)
							}
						})
						.catch((error) => console.log(error))
				}
			})
			.catch((error) => console.log(error))
github SCasarotto / casarotto-chat / src / pages / Setup / Setup.js View on Github external
.then((response) => {
				const { status, expires, permissions } = response
				if (status === 'granted') {
					ImagePicker.launchCameraAsync({
						allowsEditing: true,
						aspect: [1, 1],
						base64: true,
						quality: 0.5,
					})
						.then((response) => {
							if (!response.cancelled) {
								this.props.uploadImage(response.uri)
							}
						})
						.catch((error) => console.log(error))
				}
			})
			.catch((error) => console.log(error))
github SCasarotto / casarotto-chat / src / pages / Profile / Profile.js View on Github external
.then((response) => {
				const { status } = response
				if (status === 'granted') {
					ImagePicker.launchCameraAsync({
						allowsEditing: true,
						aspect: [1, 1],
						base64: true,
						quality: 0.5,
					})
						.then((response) => {
							if (!response.cancelled) {
								this.props.uploadImage(response.uri)
							}
						})
						.catch((error) => console.log(error))
				}
			})
			.catch((error) => console.log(error))
github NervJS / taro / packages / taro-rn / src / api / media / chooseMedia.js View on Github external
return new Promise((resolve, reject) => {
    p = isCamera ? ImagePicker.launchCameraAsync(options) : ImagePicker.launchImageLibraryAsync(options)
    p.then((resp) => {
      const { uri } = resp
      resp.path = uri
      const res = {
        tempFilePaths: [uri],
        tempFiles: [resp]
      }
      success && success(res)
      complete && complete(res)
      resolve(res)
    }).catch((err) => {
      const res = {
        errMsg: 'chooseImage fail',
        err
      }
      fail && fail(res)
github expo / expo / home / utils / ImageSelectionUtils.ts View on Github external
export async function takePhotoAsync(): Promise {
  if (!(await ensurePermissionsAsync())) return null;

  const media = await ImagePicker.launchCameraAsync(mediaOptions);
  if (!media.cancelled) {
    const asset = await MediaLibrary.createAssetAsync(media.uri);
    return await moveToPhotoCacheAsync(asset.uri);
  }
  return null;
}
github keybase / client / shared / util / expo-image-picker.tsx View on Github external
export const launchCameraAsync = (
  mediaType: 'photo' | 'video' | 'mixed',
  askPermAndRetry: boolean = true
): Promise => {
  return ImagePicker.launchCameraAsync({mediaTypes: mediaTypeToImagePickerMediaType(mediaType)}).catch(
    retyAfterAskingPerm(
      [Permissions.CAMERA, Permissions.CAMERA_ROLL],
      askPermAndRetry ? () => launchCameraAsync(mediaType, false) : null
    )
  )
}
github FaridSafi / react-native-gifted-chat / example-expo / mediaUtils.js View on Github external
export async function takePictureAsync(onSend) {
  if (await getPermissionAsync(Permissions.CAMERA)) {
    const result = await ImagePicker.launchCameraAsync({
      allowsEditing: true,
      aspect: [4, 3],
    })

    if (!result.cancelled) {
      onSend([{ image: result.uri }])
      return result.uri
    }
  }
}
github EvanBacon / firebase-instagram / screens / SelectPhotoScreen.js View on Github external
_takePhoto = async () => {
    const status = await getPermission(Permissions.CAMERA);
    if (status) {
      const result = await ImagePicker.launchCameraAsync(options);
      if (!result.cancelled) {
        this.props.navigation.navigate("NewPost", { image: result.uri });
      }
    }
  };

expo-image-picker

Provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera.

MIT
Latest version published 4 months ago

Package Health Score

91 / 100
Full package analysis