A modern, permission-friendly Android gallery picker for React Native, leveraging the native Android Photo Picker for seamless media selection.
-
Android 13+ Support: Uses the native Android Photo Picker (no
READ_MEDIA
permissions required). - Legacy Support: Fallback to classic gallery picker for Android ≤12.
-
Media Types: Select images (
image/*
) and videos (video/*
). - Customizable: Limit selection count, enable cropping, and more.
yarn add react-native-android-gallery-picker
# or
npm install react-native-android-gallery-picker
Usage
import GalleryPicker from 'react-native-android-gallery-picker';
// Pick a single photo const result = await GalleryPicker.pickMedia(); console.log(result.uri);
// Pick multiple photos const results = await GalleryPicker.pickMedia({ selectionLimit: 5 }); results.forEach(item => console.log(item.uri));
// Pick videos const video = await GalleryPicker.pickMedia({ mediaType: 'video' });
APi
Opens the gallery picker with the specified options. Options
- selectionLimit?: number - Maximum number of items that can be selected (default: 1)
- mediaType?: 'photo' | 'video' | 'mixed' - Type of media to pick (default: 'photo') Returns
- Single selection: Promise
- Multiple selection: Promise<PhotoPickerResult[]> Where PhotoPickerResult has the following structure: interface PhotoPickerResult { uri: string; }
- React Native >= 0.60.0
- Android API level >= 19
MIT
Feel free to submit a pull request or open an issue if you find any bugs or have suggestions for improvements.
After making these changes, run npm run build
to ensure everything compiles correctly, then you can publish your package using npm publish
.
Remember to:
- Test the package thoroughly
- Set up CI/CD if needed
- Consider adding example project
- Add proper error handling documentation
- Consider adding contribution guidelines