apache / cordova-plugin-camera

Apache Cordova Plugin camera
https://cordova.apache.org/
Apache License 2.0
960 stars 1.52k forks source link

getPicture on ios15 does not return callback when selecting picture #778

Open martiin93 opened 2 years ago

martiin93 commented 2 years ago

Bug Report

Problem

Using PICTURE_SOURCE_TYPE_SAVED_PHOTO_ALBUM as source on IOS 15 does not return any callback even though you have selected the image.

What is expected to happen?

The image url should be returned.

What does actually happen?

Nothing. The image selector is closed and no callback is triggered.

Information

Command or Code

 private void getImageFromSource() {
    final PhoneGap phoneGap = GWT.create(PhoneGap.class);
    PictureOptions options = new PictureOptions(100);
    options.setDestinationType(PictureOptions.DESTINATION_TYPE_FILE_URI);
    options.setEncoding(PictureOptions.CAMERA_ENCODING_TYPE_JPEG);
    int sourceType = imageSource == Source.CAMERA ? PictureOptions.PICTURE_SOURCE_TYPE_CAMERA
            : PictureOptions.PICTURE_SOURCE_TYPE_SAVED_PHOTO_ALBUM;
    options.setSourceType(sourceType);
    options.setQuality(IMAGE_QUALITY_SETTING);
    if (sourceType == PictureOptions.PICTURE_SOURCE_TYPE_CAMERA) {
        options.setAllowEdit(false);
    }
    phoneGap.getCamera().getPicture(options, new PictureCallback() {

        @Override
        public void onSuccess(String data) {
            display.setFilename(data);

            if (sourceType == PictureOptions.PICTURE_SOURCE_TYPE_SAVED_PHOTO_ALBUM
                    && phoneGap.getDevice().getPlatform().toLowerCase().equals("android")
                    && data.contains("content://")) {
                if (verifyFilepathPlugin()) {
                    resolvedNativePath = "";
                    resolveNativePath(data);
                }
            }

        }

        @Override
        public void onFailure(String message) {
            if (!message.equals("no image selected")) {
                StatusLogger.failedWhileImporting(CONST.image());
            }

        }
    });
}

Environment, Platform, Device

Phone: iPhone X OS: iOS 15.1

Version information

Cordova 10.0.0 cordova ios 6.2.0 cordova-plugin-camera 6.0.0 "Camera" cordova-plugin-file-opener2 2.0.19 "File Opener2" cordova-plugin-file-transfer 2.0.0-dev "File Transfer" cordova-plugin-file 6.0.2 "File" cordova-plugin-filepath 1.6.0 "cordova-plugin-filepath" cordova-plugin-wkwebview-file-xhr 3.0.0 "Cordova WKWebView File XHR Plugin" cordova-plugin-wkwebviewxhrfix 1.0.0 "Cordova WKWebView File XHR Fix"

Checklist

AdrianV commented 2 years ago

same for me - when you set CameraUsesGeolocation to false in your config.xml it works - but that's not a solution, just a workaround

mkattner commented 1 year ago

same for me - when you set CameraUsesGeolocation to false in your config.xml it works - but that's not a solution, just a workaround

Thanks for the fix.

But is there a reason why CameraUsesGeolocation isn't working with the library?

AdrianV commented 1 year ago

sorry I really don't remember, but it was something with a permission that the geolocation could not be extracted from the image or so.