apache / cordova-plugin-camera

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

Capture from Camera and library not working on IOS #872

Open bandeto45 opened 5 months ago

bandeto45 commented 5 months ago

Bug Report

Problem

On the latest plugin version 7.0.0, there is a problem with IOS.

What is expected to happen?

To open the camera or library and get path of the image.

What does actually happen?

There is no response when I call the camera.getPicture().

Information

In the cordova plugin camera 6.0.x works only using PHOTOLIBRARY but CAMERA does not. For Version 7.0.0 PHOTOLIBRARY and CAMERA no response at all.

Command or Code

var get_destinationType = {
            file_uri : Camera.DestinationType.FILE_URI,
            data_uri : Camera.DestinationType.DATA_URL 
            }
        var srcType = {gal : Camera.PictureSourceType.PHOTOLIBRARY, capture : Camera.PictureSourceType.CAMERA}
        var options = {

            quality: 100,
            destinationType: get_destinationType[file_desc],
            // In this app, dynamically set the picture source, Camera or photo gallery
            sourceType: srcType[tp],
            encodingType: Camera.EncodingType.PNG,
            mediaType: Camera.MediaType.PICTURE,
            correctOrientation: true
        }
        let cam = this;
        console.log(options)
        let success_img = (img)=>{
            sessionStorage.setItem('uri', img);
            console.log(img)

        }
        let error_img = (e)=>{
            get_media.f7.preloader.hide();
            this.f7.preloader.hide();

            console.log("Error getting picture: " + e);
        }
        navigator.camera.getPicture(success_img, error_img, options);   
    }

CONFIG.xml


<?xml version='1.0' encoding='utf-8'?>
<widget id="com.app.project" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Swak Merchant</name>
    <description>Sample Apache Cordova App</description>
    <author email="dev@cordova.apache.org" href="https://cordova.apache.org">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />

    <allow-navigation href="*" />

    <platform name="android">
      <preference name="StatusBarOverlaysWebView" value="false" />
      <preference name="android-minSdkVersion" value="22" />
      <preference name="android-targetSdkVersion" value="34" />
      <preference name="SplashMaintainAspectRatio" value="true" />
      <splash density="land-hdpi" src="res/screen/android/drawable-hdpi/screen.png" />
      <splash density="land-mdpi" src="res/screen/android/drawable-mdpi/screen.png" />
      <splash density="land-xhdpi" src="res/screen/android/drawable-xhdpi/screen.png" />
      <splash density="land-xxhdpi" src="res/screen/android/drawable-xxhdpi/screen.png" />
      <splash density="land-xxxhdpi" src="res/screen/android/drawable-xxxhdpi/screen.png" />
      <splash density="port-hdpi" src="res/screen/android/drawable-hdpi/screen.png" />
      <splash density="port-mdpi" src="res/screen/android/drawable-mdpi/screen.png" />
      <splash density="port-xhdpi" src="res/screen/android/drawable-xhdpi/screen.png" />
      <splash density="port-xxhdpi" src="res/screen/android/drawable-xxhdpi/screen.png" />
      <splash density="port-xxxhdpi" src="res/screen/android/drawable-xxxhdpi/screen.png" />
      <icon density="ldpi" src="res/icon/android/mipmap-ldpi/ic_launcher.png" />
      <icon density="mdpi" src="res/icon/android/mipmap-mdpi/ic_launcher.png" />
      <icon density="hdpi" src="res/icon/android/mipmap-hdpi/ic_launcher.png" />
      <icon density="xhdpi" src="res/icon/android/mipmap-xhdpi/ic_launcher.png" />
      <icon density="xxhdpi" src="res/icon/android/mipmap-xxhdpi/ic_launcher.png" />
      <icon density="xxxhdpi" src="res/icon/android/mipmap-xxxhdpi/ic_launcher.png" />
      <preference name="AndroidWindowSplashScreenAnimatedIcon" value="res/screen/android/splashscreen.xml" />
      <!-- <hook type="after_prepare" src="hooks/stripExtraWritePerm.js" /> -->

    </platform>

    <platform name="ios">
      <config-file parent="CFBundleAllowMixedLocalizations" platform="ios" target="*-Info.plist">
        <true />
      </config-file>
      <preference name="scheme" value="app" />
      <preference name="hostname" value="localhost" />
      <preference name="StatusBarOverlaysWebView" value="true" />
      <splash src="res/screen/ios/Default@2x~universal~anyany.png" />
      <icon height="180" src="res/icon/ios/icon-60x60@3x.png" width="180" />
      <icon height="60" src="res/icon/ios/icon-60x60@1x.png" width="60" />
      <icon height="120" src="res/icon/ios/icon-60x60@2x.png" width="120" />
      <icon height="76" src="res/icon/ios/icon-76x76@1x.png" width="76" />
      <icon height="152" src="res/icon/ios/icon-76x76@2x.png" width="152" />
      <icon height="228" src="res/icon/ios/icon-76x76@3x.png" width="228" />
      <icon height="40" src="res/icon/ios/icon-40x40@1x.png" width="40" />
      <icon height="80" src="res/icon/ios/icon-40x40@2x.png" width="80" />
      <icon height="87" src="res/icon/ios/icon-29x29@3x.png" width="87" />
      <icon height="57" src="res/icon/ios/icon-57x57@1x.png" width="57" />
      <icon height="114" src="res/icon/ios/icon-57x57@2x.png" width="114" />
      <icon height="72" src="res/icon/ios/icon-72x72@1x.png" width="72" />
      <icon height="144" src="res/icon/ios/icon-72x72@2x.png" width="144" />
      <icon height="167" src="res/icon/ios/icon-83.5x83.5@2x.png" width="167" />
      <icon height="29" src="res/icon/ios/icon-29x29@1x.png" width="29" />
      <icon height="58" src="res/icon/ios/icon-29x29@2x.png" width="58" />
      <icon height="50" src="res/icon/ios/icon-50x50@1x.png" width="50" />
      <icon height="100" src="res/icon/ios/icon-50x50@2x.png" width="100" />
      <icon height="167" src="res/icon/ios/icon-83.5x83.5@2x.png" width="167" />
      <icon height="1024" src="res/icon/ios/icon-512x512@2x.png" width="1024" />
<edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
            <string>need location access to find things nearby</string>
        </edit-config>
        <edit-config target="NSLocationAlwaysAndWhenInUseUsageDescription" file="*-Info.plist" mode="merge">
            <string>need location access to find things nearby</string>
        </edit-config>
        <edit-config target="NSLocationAlwaysUsageDescription" file="*-Info.plist" mode="merge">
            <string>need location access to find things nearby</string>
        </edit-config> 
        <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
            <string>To provide you with the best features , our app needs access to your camera, to upload product, attach photos in messaging, sending reports and changing profile picture.</string>
        </edit-config>
        <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
            <string>To provide you with the best features, our app needs photo library access to get pictures from your device,  to upload product, attach photos in messaging, sending reports and changing profile picture.</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>
        <preference name="iosPersistentFileLocation" value="Library" />

        <preference name="iosPersistentFileLocation" value="Compatibility" />
        <preference name="CameraUsesGeolocation" value="false" />

    </platform>

    <preference name="DisallowOverscroll" value="true" />
    <preference name="BackupWebStorage" value="local" />
    <preference name="AutoHideSplashScreen" value="false" />
    <preference name="ShowSplashScreenSpinner" value="false" />
    <preference name="SplashScreenDelay" value="0" />
    <preference name="Suppresses3DTouchGesture" value="true" />
    <preference name="Allow3DTouchLinkPreview" value="false" />
    <preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
    <preference name="AllowInlineMediaPlayback" value="true" />
</widget>

Environment, Platform, Device

IOS

Version information

cordova ios 7.0.1 cordova plugin 7.0.0

Checklist

marutifh commented 3 months ago

Hi @bandeto45 ,

Did you find any solution to this? stuck with same issue.