Search code examples
iosflutterimage-galleryphoto-galleryimagepicker

Limited access to photos giving full access on iOS, when using image_picker on flutter


I want to upload user's selected photo to server using image_picker plugin for flutter. But, when user is selecting limited access to photos and selecting photos that can be visible to app, it is showing full library with all photos.

I am using image_picker with this code:

      final ImagePicker imagePicker = ImagePicker();

      // Check for gallery permission
      final hasPermission = await requestPhotosPermission();

      if (!hasPermission) return false;

      final photoResult = await imagePicker.pickImage(
          source: ImageSource.gallery,
          maxHeight: 1280,
          maxWidth: 800,
          requestFullMetadata: false);

I have added permissions to info.plist as well

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Access to the photo library is necessary.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Access to the photo library is necessary.</string>

Below is an error log after selecting photos and click done. It is showing all photos rather then selected ones.

**[core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)""
[PAAccessLogger] Failed to log access with error: access=<PATCCAccess 0x283311110> accessor:<<PAApplication 0x283311120 identifierType:auditToken identifier:{pid:1112, version:3545}>> identifier:D4D1111-F111-4798-1111-F1911111A9E0 kind:intervalEvent timestampAdjustment:0 visibilityState:0 assetIdentifierCount:0 tccService:kTCCServicePhotos, error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service with pid 226 named com.apple.privacyaccountingd" UserInfo={NSDebugDescription=connection to service with pid 226 named com.apple.privacyaccountingd}**

Any solutions? Thanks.


Solution

  • After researching I have found that I don't need to ask permission for image_picker plugin. Therefore, for not getting error with full photos permission even when we gave limited photos permission - just don't ask it at all. Maybe, on some devices even on shared area photos can be restricted and it needs permission, by that way, I don't know how to fix it.