Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[image_picker] [PHPhotoLibrary authorizationStatus] status is not correct in iOS14+ #113681

Closed
zhouxing5311 opened this issue Oct 19, 2022 · 14 comments · Fixed by flutter/plugins#6845
Assignees
Labels
c: proposal A detailed proposal for a change to Flutter p: image_picker The Image Picker plugin. P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically

Comments

@zhouxing5311
Copy link

it is not correct using [PHPhotoLibrary authorizationStatus] to get the authorization status in iOS14+. such as when you limit your app can access only some photos, then [PHPhotoLibrary authorizationStatus] will return PHAuthorizationStatusAuthorized which is not correct.
to solve the problem, you should use [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite] in iOS14+ to get the correct result.

@huycozy huycozy added the in triage Presently being triaged by the triage team label Oct 19, 2022
@huycozy
Copy link
Member

huycozy commented Oct 19, 2022

Hi @zhouxing5311
I'm not sure I can get the context of the issue. Please elaborate the issue in more detail by indicating whether it is related to the Flutter framework or a specific plugin you are using.

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 19, 2022
@zhouxing5311
Copy link
Author

sorry for that, it is in image_picker_ios plugin, class name is FLTImagePickerPlugin.m, method name is checkPhotoAuthorizationForAccessLevel.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 19, 2022
@huycozy
Copy link
Member

huycozy commented Oct 20, 2022

@zhouxing5311
I try modifying authorizationStatus to authorizationStatusForAccessLevel:PHAccessLevelReadWrite but the result is still the same. I'm testing on iPhone 14 Pro Max, iOS 16.0.

Demo
Screen.Recording.2022-10-20.at.10.02.09.mov
Modified snippet code
- (void)checkPhotoAuthorizationForAccessLevel API_AVAILABLE(ios(14)) {
  PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatusForAccessLevel:PHAccessLevelReadWrite];

Which iOS version did you try?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 20, 2022
@zhouxing5311
Copy link
Author

@zhouxing5311 I try modifying authorizationStatus to authorizationStatusForAccessLevel:PHAccessLevelReadWrite but the result is still the same. I'm testing on iPhone 14 Pro Max, iOS 16.0.

Demo
Screen.Recording.2022-10-20.at.10.02.09.mov
Modified snippet code
Which iOS version did you try?

maybe i did't make my point, image selecting behavior has no problem, the question is PHPhotoLibrary authorizationStatus return the result 'PHAuthorizationStatusAuthorized', but the result should be 'PHAuthorizationStatusLimited' , here is my code result.
image

the reason I bring this up is that i want to show diffrent image select page when your permission is limitted by modifying the source code, so i need to get the correct authorizationStatus. maybe you will add the feature like this to source code?
image

or when i finish this, i can submit a pull request. i think this is a better experience for user who selected the limited photos. the present behavior may confusing the user that the original image selecting is invalid.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 20, 2022
@huycozy
Copy link
Member

huycozy commented Oct 20, 2022

@zhouxing5311
Please check this issue if it's similar to your case: #110176

Also, I re-test this thing again, looks like it has been implemented similar to what you're describing (although the Select more photos dialog shows only once and the design is different), please see in demo:

Demo (Select more photos)
Screen.Recording.2022-10-20.at.11.06.13.mov

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 20, 2022
@zhouxing5311
Copy link
Author

@zhouxing5311 Please check this issue if it's similar to your case: #110176

Also, I re-test this thing again, looks like it has been implemented similar to what you're describing (although the Select more photos dialog shows only once and the design is different), please see in demo:

Demo (Select more photos)

hi, i don't think this is a similar case, the handling for limit photos is not suitable i think. after selecting the special photos, next time the image picker should show the photos only which is selected by user at the begin time. or the previous selecting is useless, users can not understand what's meaning of the begining select.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Oct 24, 2022
@huycozy
Copy link
Member

huycozy commented Oct 25, 2022

@zhouxing5311 Labeling the issue as a proposal for further insight from the team.

Plugin: image_picker_ios: ^0.8.6+1

flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.3.5, on macOS 12.6 21G115 darwin-x64, locale en-VN)
    • Flutter version 3.3.5 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d9111f6402 (9 hours ago), 2022-10-19 12:27:13 -0700
    • Engine revision 3ad69d7be3
    • Dart version 2.18.2
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode14.0.1.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.5
    • Dart plugin version 222.4167.21

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.72.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • 332079AF-E895-4685-910E-7B1E18B0C6B8 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-0 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • macOS 12.6 21G115 darwin-x64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 106.0.5249.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[!] Flutter (Channel master, 3.5.0-10.0.pre.67, on macOS 12.6 21G115 darwin-x64, locale en-VN)
    • Flutter version 3.5.0-10.0.pre.67 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e62d519cb5 (18 minutes ago), 2022-10-24 21:56:13 -0400
    • Engine revision 75bfcd73ca
    • Dart version 2.19.0 (build 2.19.0-330.0.dev)
    • DevTools version 2.18.0
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 31.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode14.0.1.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 70.0.5
    • Dart plugin version 222.4167.21

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.72.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.50.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 12 (API 31)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 12.6 21G115 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 106.0.5249.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

@huycozy huycozy added platform-ios iOS applications specifically plugin p: image_picker The Image Picker plugin. c: proposal A detailed proposal for a change to Flutter and removed in triage Presently being triaged by the triage team labels Oct 25, 2022
@huycozy huycozy changed the title [PHPhotoLibrary authorizationStatus] status is not correct in iOS14+ [image_picker] [PHPhotoLibrary authorizationStatus] status is not correct in iOS14+ Oct 25, 2022
@stuartmorgan
Copy link
Contributor

Most of the discussion above has been focused on the code, but without any context on what the behavior is, which makes it hard to understand what exactly is being reported. What is the developer and/or end-user impact of the code changes you are suggesting?

@stuartmorgan stuartmorgan added the P3 Issues that are less important to the Flutter project label Oct 27, 2022
@zhouxing5311
Copy link
Author

zhouxing5311 commented Oct 28, 2022

hi, the behavior we wants to is this. image_picker will open this page when users used the limiting photo permission.
https://user-images.githubusercontent.com/14874355/198476452-6821888e-c910-4ea0-b177-740947c65b3a.mov

i have finish this at my forked repo, you can see the changes. this is only a suggestion, the behavior now is ok too.
zhouxing5311/plugins@67f4eea

@csbence10
Copy link

csbence10 commented Nov 3, 2022

Hi!

We are facing this issue too. If the user only gives access to some of their photos, while picking photos all of them can be picked. It is not the expected behaviour. Only the selected photos should be shown while picking images.
So for example in the video captured by @huycozy :

  • at the beginning we can see the selected photos - only the first row, the first three images are selected
  • after that while picking photos all six photos can be picked. The expected behaviour would be that while picking photos only the first 3 should be shown to select from.

@zhouxing5311
Copy link
Author

Hi!

We are facing this issue too. If the user only gives access to some of their photos, while picking photos all of them can be picked. It is not the expected behaviour. Only the selected photos should be shown while picking images. So for example in the video captured by @huycozy :

  • at the beginning we can see the selected photos - only the first row, the first three images are selected
  • after that while picking photos all six photos can be picked. The expected behaviour would be that while picking photos only the first 3 should be shown to select from.

i have changed some code in my forked repo to change the behavior. you can see the details in this change zhouxing5311/plugins@67f4eea

if you want to test the new behavior, you can add the following override code in your pubspec.yaml.

dependency_overrides:
  image_picker_ios:
    git:
      url: https://gitee.com/zhouxing5318/image_picker_ios

@hellohuanlin
Copy link
Contributor

If the user only gives access to some of their photos, while picking photos all of them can be picked. It is not the expected behaviour. Only the selected photos should be shown while picking images.

@csbence10 Your issue is probably a separate bug. IIRC It is because we used PHPickerViewController in our implementation, which is in a different process and handles its own permission (so it has the access to all images, despite that you chose selected images in permission alert). This is indeed confusing behavior and we shouldn't ask for permission if using PHPickerViewController, so need to update that (i believe there's already an issue tracking your problem, but forgot which one)

@jmagman
Copy link
Member

jmagman commented Dec 9, 2022

cc @vashworth

@github-actions
Copy link

github-actions bot commented Mar 4, 2023

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 4, 2023
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: proposal A detailed proposal for a change to Flutter p: image_picker The Image Picker plugin. P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants