Skip to content

witPranav/react-native-photo-picker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
  • ???

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published