@witpranav/react-native-photo-picker
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

react-native-photo-picker

Getting started

$ npm install @witpranav/react-native-photo-picker

Note

  • This module works only for android at the moment.

How it works

-- This module uses the new PhotoPicker API introduced in Android 11.

-- Since this API is backported, the module also works with previous versions of Android.

Usage

  • Goto app level build.gradle in android/app/build.gradle and add the following block at the end of the file.
configurations.implementation {
    exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8'
}

-- If backported photo picker support is needed as well, insert the following entry inside the application tag in your apps manifest file

<service android:name="com.google.android.gms.metadata.ModuleDependencies"
         android:enabled="false"
         android:exported="false">
    <intent-filter>
        <action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
    </intent-filter>
    <meta-data android:name="photopicker_activity:0:required" android:value="" />
</service>

-- Javascript

import {launchPhotoPicker, StatusConstants} from '@witpranav/react-native-photo-picker';

launchPhotoPicker(
    {
    mediaType: 'ImageAndVideo', //optional prop; possible values can be ImageAndVideo, ImageOnly, VideoOnly; defaults to ImageAndVideo
    multipleMedia: true, //optional prop; defaults to false
    mimeType: "image/gif" //optional prop;
    },
    (res: any) => {
      if (res.status === StatusConstants.STATUS_CANCELLED) {
        //process cancelled res.error
      }
      if (res.status === StatusConstants.STATUS_SUCCESS) {
        // process success res.uris
      }
      if (res.status === StatusConstants.STATUS_ERROR) {
        // process error res.error
      }
    },
  );

-- More information on mimetypes here.

TODO

  • Add Persist Media File Permission.
  • Convert to Fabric
  • Add count limit to files
  • ???

Package Sidebar

Install

npm i @witpranav/react-native-photo-picker

Weekly Downloads

0

Version

1.0.8

License

MIT

Unpacked Size

18.6 kB

Total Files

11

Last publish

Collaborators

  • witpranav