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

No result with mediaType SAVEDPHOTOALBUM and enabled CameraUsesGeolocation (iOS) #702

Closed
3 tasks done
sven-s opened this issue Jan 4, 2021 · 7 comments
Closed
3 tasks done

Comments

@sven-s
Copy link

sven-s commented Jan 4, 2021

Bug Report

Problem

getPicture does not return an image when using mediaType SAVEDPHOTOALBUM with enabled CameraUsesGeolocation preference setting.

What is expected to happen?

When selecting an image from the camera roll and enabled CameraUsesGeolocation preference setting, the image should be returned from the plugin.

What does actually happen?

The function returns a promise, which will never be completed.

Information

When setting the CameraUsesGeolocation setting to false, the plugin works as expected, but I have an application, where the user is able to select both options.

Command or Code

Environment, Platform, Device

Cordova 10.0.0
iOS Platform 6.1.1
iPhone OS 14.3

Version information

Ionic 1.3.4
Xcode 12.3

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@codeconsole
Copy link
Contributor

I have created a very easy to run example that demonstrates the non working behavior:
https://github.com/codeconsole/exiftest

% cordova --version
10.0.0
  git clone https://github.com/codeconsole/exiftest
  cd exiftest
  cordova prepare
  cordova run ios

Verify selecting an image works. In the simulator, click the Photo Library button, choose an image and then notice the image is shown and a popup comes up with some partial exif info.

Now to break everything then CameraUsesGeolocation to true in config.xml and run again.

  ./setCameraUsesGeolocation.sh true
  cordova run ios

click the Photo Library button, choose a photo and notice nothing happens. Neither the success or error callbacks get executed for navigator.camera.getPicture()

Bonus points:
Open the workspace in xcode

open platforms/ios/HelloCordova.xcworkspace

and run the project

Notice the same behavior and the following message is shown in the console when nothing happens:

2021-02-21 16:55:30.974760-0800 HelloCordova[94981:4291237] [HelloCordova] copyThumbnail:301: *** skipping thumbnail -- too big [26417 bytes]

@bojanbizjak
Copy link

Same here.

Callback onSuccess is never called when using mediaType SAVEDPHOTOALBUM with enabled CameraUsesGeolocation preference setting.

Options:

{
                quality: 100,
                destinationType: Camera.DestinationType.FILE_URI,
                sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
                saveToPhotoAlbum: false,
                mediaType: Camera.MediaType.PICTURE
            }

Environment, Platform, Device
Cordova 10.0.0
iOS Platform 6.2.0
iPhone OS 14.4.1 (iPhone 7 Plus)
cordova-plugin-camera: 5.0.1,

Version information
Xcode 12.4

@codeconsole
Copy link
Contributor

Have you tried installing the modified plugin?
cordova plugin add https://github.com/codeconsole/cordova-plugin-camera.git#ryaa

@bojanbizjak
Copy link

Unfortunately, https://github.com/codeconsole/cordova-plugin-camera.git#ryaa (cordova-plugin-camera 5.0.2-dev) doesn't work either. Callback onSuccess is never called.

@codeconsole
Copy link
Contributor

you tried the ryaa branch (master is just the same as the fork)?

@ToddEllering
Copy link

Having the same issue with:
Cordova 10.0.0
iOS Platform 6.2.0
iPhone OS 14.6 (iPhone 7 Plus)
cordova-plugin-camera: 5.0.2

success callback is never called when sourceType is navigator.camera.PictureSourceType.SAVEDPHOTOALBUM

The image select comes up, and can pick an image, but then nothing. sourceType navigator.camera.DestinationType.FILE_URI works fine.

@erisu
Copy link
Member

erisu commented Mar 22, 2022

I am unable to reproduce this issue with the current master branch.

I will close out this issue as unreproducible.

If you are still experiencing the issue with master branch, please create a new ticket and:

  1. create and link a simple reproduction repo.
  2. provide additional steps, if necessary, to run the reproduction repo to see the issue.

Code Sample:

Simple JavaScript index.js

document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady() {
  // encodingType: Camera.EncodingType.JPEG,
  const cameraOptions = {
    quality: 100,
    destinationType: Camera.DestinationType.FILE_URI,
    sourceType: Camera.PictureSourceType.SAVEDPHOTOALBUM,
    mediaType: Camera.MediaType.PICTURE,
    saveToPhotoAlbum: false
  }

  function onSuccess(result) {
    var image = document.getElementById('myImage');
    image.src = result;
  }

  function onFail(message) {
    alert('Failed because: ' + message);
  }

  document.getElementById('cameraTakePhoto').onclick = function() {
    navigator.camera.getPicture(onSuccess, onFail, cameraOptions);
  };
}

iOS config.xml Snippet

<platform name="ios">
    <preference name="CameraUsesGeolocation" value="true" />

    <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 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 photo library access to save pictures there</string>
    </edit-config>
</platform>

@erisu erisu closed this as completed Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants