Skip to content

Commit

Permalink
docs: Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
CaiJingLong committed Sep 19, 2023
1 parent 7a223d0 commit 49013d0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
17 changes: 14 additions & 3 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,11 @@ Android 10 引入了 **Scoped Storage**,导致原始资源文件不能通过

```dart
final PermissionState ps = await PhotoManager.requestPermissionExtend();
if (ps.hasAccess) {
if (ps.isAuth) {
// 已获取到权限
} else if (ps.hasAccess) {
// 已获取到权限(哪怕只是有限的访问权限)。
// iOS Android 目前都已经有了部分权限的概念。
} else {
// 权限受限制(iOS)或者被拒绝,使用 `==` 能够更准确的判断是受限还是拒绝。
// 你可以使用 `PhotoManager.openSetting()` 打开系统设置页面进行进一步的逻辑定制。
Expand All @@ -228,14 +231,22 @@ PhotoManager.setIgnorePermissionCheck(true);

对于一些后台操作(应用未启动等)而言,忽略检查是比较合适的做法。

#### iOS 受限的资源权限
#### 受限的资源权限

##### iOS 受限的资源权限

iOS14 引入了部分资源限制的权限 (`PermissionState.limited`)。
`PhotoManager.requestPermissionExtend()` 会返回当前的权限状态 `PermissionState`
详情请参阅 [PHAuthorizationStatus][]

如果你想要重新选择在应用里能够读取到的资源,你可以使用 `PhotoManager.presentLimited()` 重新选择资源,
这个方法仅在 iOS 14 以上的版本生效,其他平台或版本无法调用这个方法。
这个方法对于 iOS 14 以上的版本生效。

##### Android 受限的资源权限

和 iOS 类似,安卓 14(API 34) 中也加入了这个概念,dart 端的使用方法也完全一致。

但行为上略有不同(基于模拟器),安卓中一旦授予某个资源的访问权限,就无法撤销,即使再次使用 `presentLimited` 时不选中也一样。

### 获取相簿或图集 (`AssetPathEntity`)

Expand Down
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,11 @@ Most of the APIs can only use with granted permission.

```dart
final PermissionState ps = await PhotoManager.requestPermissionExtend(); // the method can use optional param `permission`.
if (ps.hasAccess) {
// Granted or limited.
if (ps.isAuth) {
// Granted
// You can to get assets here.
} else if (ps.hasAccess) {
// Access will continue, but the amount visible depends on the user's selection.
} else {
// Limited(iOS) or Rejected, use `==` for more precise judgements.
// You can call `PhotoManager.openSetting()` to open settings for further steps.
Expand All @@ -240,7 +243,9 @@ PhotoManager.setIgnorePermissionCheck(true);
For background processing (such as when the app is not in the foreground),
ignore permissions check would be proper solution.

#### Limited entities access on iOS
#### Limited entities access

##### Limited entities access on iOS

With iOS 14 released, Apple brought a "Limited Photos Library" permission
(`PermissionState.limited`) to iOS.
Expand All @@ -251,8 +256,16 @@ To reselect accessible entities for the app,
use `PhotoManager.presentLimited()` to call the modal of
accessible entities' management.
This method only available for iOS 14+ and when the permission state
is limited (`PermissionState.limited`),
other platform won't make a valid call.
is limited (`PermissionState.limited`).

##### Limited entities access on android

Similar to iOS, Android 14 (API 34) has also introduced this concept, and the usage on the Dart side is completely identical.

However, there is a slight difference in behavior (based on the emulator).

In Android, once access permission to a certain resource is granted, it cannot be revoked,
even if you do not select it again when using `presentLimited`.

### Get albums/folders (`AssetPathEntity`)

Expand Down

0 comments on commit 49013d0

Please sign in to comment.