1
  // add no of images equal to Qty

handleQuantity(qty) {
    this.setState({ qty: qty })
    for (let i = 0; i < qty; i++) {
        this.selectPhotoTapped(i)
    }

}



selectPhotoTapped(count) {
    const options = {
        quality: 1.0,
        maxWidth: 500,
        maxHeight: 500,
        storageOptions: {
            skipBackup: true
        }
    };

    ImagePicker.launchCamera(options, (response) => {
        console.log(response);
        if (response.didCancel) {
            console.log('User cancelled photo picker');
        }
        else if (response.error) {
            console.log('ImagePicker Error: ', response.error);
        }
        else {
            //let source = { uri: response.uri };
            // this.setState({
            //     ImageSourceArr: [...this.state.ImageSourceArr, source]
            // });
            Realm.open(databaseOptions).then(realm => {
                realm.write(() => {
                    realm.create(Images_SCHEMA, {
                        id: count,
                        path: response.uri
                    });

                    // this.setState({ size: realm.objects(Images_SCHEMA).length });
                    const res = realm.objects(Images_SCHEMA)
                    let res2 = JSON.parse(JSON.stringify(res))
                    for (let key in res2) {
                        this.setState({
                            ImageSourceArr: [...this.state.ImageSourceArr, res2[key].path],
                            size: realm.objects(Images_SCHEMA).length
                        });
                    }
                });
            });

        }

    });

}

handleQuantity() function call no of quantity times selectedPhototap() function and selectedPhotoTap() function insert path into realm , but the problem is that it store only last image path,i want to insert all images that capture by function selectedPhotoTap Please anybody help me

1 Answers1

0

react-native-image-picker does not support for multiple image selection, crop tool, and landscape support for native iOS functionality - not issues with the library. If you need these things, react-native-image-crop-picker might be a better choice for you.

https://github.com/ivpusic/react-native-image-crop-picker

Lovlesh Pokra
  • 722
  • 4
  • 14
  • 2
    maxFile feature not supported by Android – Shoeb Siddique Jun 27 '19 at 09:57
  • @ShoebSiddique I don't think there is a react-native library that supports picking multiple photos at a time on android up to a maximum amount. You can still use this library and only use the first x images returned from the array though. – Dror Bar Jul 31 '19 at 22:45