Cordova相机插件IOS 11无法从库中选择图像

15

我正在使用 ionicXcodecordova-plugin-camera 访问我的 iPhone 库。它正在运行 IOS 11.1.2。

我猜想所有的授权都已经设置好了,但是当我从图像库中点击一张图片(图像选择器正在显示)时,我会得到这个错误:

[discovery] errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}

根据这个主题: PhotoPicker discovery error: Error Domain=PlugInKit Code=13 看来这可能是一个权限不足的错误。

正如您下面所看到的,Info.plist 已经设置好了,我找不到我的错误在哪里,有什么想法吗?

enter image description hereenter image description hereenter image description hereenter image description here

// FUNCTION TO OPEN MY IPHONE'S LIBRARY AND SELECT A PIC

$scope.takePic = function()
{
    navigator.camera.getPicture(
    function(uri){
        //console.log(uri);
    },

    function(){
    $ionicPopup.alert({
          title: 'Error',
          template: 'Impossible'
          });
    },
    {
     destinationType: 1,
     sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
     allowEdit: false,
     saveToPhotoAlbum: false,
     quality: 30,
     }
     );

};
<!--LINES ADDING IN MY CONFIG.XML TO SET THE INFO.PLIST FILE -->

<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
    <string>need camera access to take pictures</string>
</edit-config>

<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
    <string>need to photo library access to get pictures from there</string>
</edit-config>

<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
    <string>need location access to find things nearby</string>
</edit-config>

<edit-config target="NSPhotoLibraryAddUsageDescription" file="*-Info.plist" mode="merge">
    <string>need to photo library access to save pictures there</string>
</edit-config>

<!-- BUTTON THAT IS CALLING THE FUNCTION -->

<button ng-click="takePic()" style="font-weight:300;border-radius:10px 10px 10px 10px;" class="button button-positive button-block">Take picture</button>


我有同样的问题。 - Sifeng
你有没有找到解决办法? - DigitalMystery
1个回答

0

遇到了完全相同的问题。阅读文档,它指定:

NSPhotoLibraryUsageDescription 尽管此键控制对用户照片库的读写访问权限,但如果您的应用程序只需要向库中添加资源而不需要读取任何资源,则最好使用NSPhotoLibraryAddUsageDescription。

所以从技术上讲,只使用NSPhotoLibraryUsageDescription应该就足够了。尝试删除NSPhotoLibraryAddUsageDescription,但没有任何区别,无论有没有它,我仍然收到相同的错误消息。


2
自从我发布了这个问题后,这个问题不幸地仍然存在...最终我决定使用相机拍照而不是使用用户的图片库。目前来说,它能够完成任务,只需要使用一张图片来设置头像。如果我找到了解决方案,我会告诉你的,希望你也能这样做,谢谢 ;) - Memphis
你找到解决方案了吗? - Seb
你有没有回去尝试使用库,还是仍然只使用相机? - DigitalMystery

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接