Skip to content

Commit

Permalink
Update to v7.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nkalupahana committed Oct 29, 2024
1 parent 8038b04 commit 952c566
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 44 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [7.0.0](https://github.com/capacitor-community/media/compare/v7.0.0...v6.0.0) (2024-08-28)
- Add duration to `getMedias()` videos
- Permissions are no longer required on Android for non-gallery use (BREAKING)
- Added gallery functionality on Android to access all albums on device (BREAKING)

## [6.0.0](https://github.com/capacitor-community/media/compare/v5.4.1...v6.0.0) (2024-04-29)
- Update to Capacitor 6
- Fix missing source maps
Expand Down
110 changes: 71 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,83 @@ This plugin is currently for Capacitor 6. Add an `@5` at the end to install for

After installing, be sure to sync by running `ionic cap sync`.

## Migrating to v7

There has been a breaking change to the way permissions are handled on Android.
- If your app is not a "gallery" app (does not need access to all photo albums on the device, just its own), you no longer need the `READ_EXTERNAL_STORAGE`, `WRITE_EXTERNAL_STORAGE`, `READ_MEDIA_IMAGES`, or `READ_MEDIA_VIDEO` permissions. You can remove them from your `AndroidManifest.xml` file. The plugin will no longer request any permissions to save images to your app's albums.
- If your app is a gallery app and you need access to all albums on the device, you'll need to update your `capacitor.config.ts` file -- see the setup instructions below.

You will need to update to v7 to publish an app with this plugin on the Google Play Store.

## Migrating to Capacitor 6

There are a few breaking changes to take note of:
- `saveGif` no longer exists. Use `savePhoto` for images and GIFs.
- Error text has been changed. If you were checking for specific error messages, you should now use `error.code`, which will be `accessDenied`, `argumentError`, `downloadError`, or `filesystemError`.

## Setup

### iOS

You'll need to add the following to your app's `Info.plist` file:

```xml
<dict>
...
<key>NSPhotoLibraryUsageDescription</key>
<string>Describe why you need access to user's photos (getting albums and media)</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Describe why you need to add photos to user's photo library</string>
...
</dict>
```

### Android

By default, this plugin only has access to the albums associated with the
app it's installed in. For this basic level of access, you only need to add
the following permission:

```xml
<manifest>
...
<uses-permission android:name="android.permission.INTERNET" />
...
</manifest>
```

If you're building an app that needs to access all photos and videos on the device
(e.g. a photo gallery app), you'll need the following permissions:

```xml
<manifest>
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
...
```

You'll also need to add the following configuration to `capacitor.config.ts`:

```ts
plugins: {
Media: {
androidGalleryMode: true
}
}
```

You can find an example of how this should look in the `example/` folder.

## Demo

Go the the `example/` folder to play with an example app that should show all functionality of this plugin.

<img style="width: 250px" src="https://github.com/capacitor-community/media/blob/main/example_app.png?raw=true" />

## API

Unless otherwise noted, there should be full feature parity between iOS and Android. Web is not supported.
Expand Down Expand Up @@ -358,45 +429,6 @@ Attributes to sort media by.

</docgen-api>

## iOS

You'll need to add the following to your app's `Info.plist` file:

```xml
<dict>
...
<key>NSPhotoLibraryUsageDescription</key>
<string>Describe why you need access to user's photos (getting albums and media)</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Describe why you need to add photos to user's photo library</string>
...
</dict>
```

## Android

You'll need to add the following to your app's `AndroidManifest.xml` file:

```xml
<manifest>
...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
...
</manifest>
```

Note the READ_MEDIA permissions -- these are **new in Android 13**!

## Demo

Go the the `example/` folder to play with an example app that should show all functionality of this plugin.

<img style="width: 250px" src="https://github.com/capacitor-community/media/blob/main/example_app.png?raw=true" />

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down
2 changes: 1 addition & 1 deletion example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@capacitor-community/media",
"version": "6.0.1",
"version": "7.0.0",
"description": "Enable some media features for Capacitor such as create albums, save videos, gifs and more.",
"author": "Stewan Silva",
"author": "Nisala Kalupahana",
"license": "MIT",
"main": "dist/plugin.cjs.js",
"module": "dist/esm/index.js",
Expand Down

0 comments on commit 952c566

Please sign in to comment.