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

[ionic-native v5] Camera doesn't work #2635

Closed
peterpeterparker opened this issue Aug 12, 2018 · 2 comments
Closed

[ionic-native v5] Camera doesn't work #2635

peterpeterparker opened this issue Aug 12, 2018 · 2 comments

Comments

@peterpeterparker
Copy link
Contributor

peterpeterparker commented Aug 12, 2018

I'm submitting a ... (check one with "x")
[X] bug report

Current behavior:
I'm migrating my code from an Ionic v3 app to Ionic v4 app, the same piece of code regarding the camera plugin doesn't work. I don't face any error at build time or at run time, I've no log information but when I take a picture or try to update a photo from the gallery on my real iPhons 6s / iOS 11.4 the resulting photo is a 0x0 pixels photo

Expected behavior:
Being able to use the camera plugin as I do in my Ionic v3 app

Steps to reproduce:

  1. Use the following code (see related code)
  2. In an Ionic v4 app
  3. Using 5.0.0-beta.14

Related code:

import {Camera, CameraOptions, CameraPopoverOptions} from '@ionic-native/camera/ngx';

    const popoverOptions: CameraPopoverOptions = {
        x: 250,
        y: 430,
        width: 100,
        height: 200,
        arrowDir: this.camera.PopoverArrowDirection.ARROW_LEFT
    };

    const options: CameraOptions = {
        quality: 100,
        destinationType: this.camera.DestinationType.FILE_URI,
        sourceType: this.camera.PictureSourceType.CAMERA,
        allowEdit: false,
        encodingType: this.camera.EncodingType.JPEG,
        targetWidth: 1280,
        targetHeight: 1280,
        mediaType: this.camera.MediaType.PICTURE,
        correctOrientation: true,
        saveToPhotoAlbum: false,
        cameraDirection: this.camera.Direction.BACK,
        popoverOptions: popoverOptions
    };

    this.camera.getPicture(options).then((imageURI: string) => {
        console.log(imageURI);
     });

Console.log
Console.log gives the following result:

 file:///var/mobile/Containers/Data/Application/710296D6-.....DF/tmp/cdv_photo_002.jpg

which is according the debug 0x0 pixels wide

Extra info

I'm using cordova-plugin-ionic-webview v2.0.1 and using the following function to normalize the urls

 static wkWebViewFileURI(uri: string): string {
    if (uri && uri.indexOf('file://') > -1) {
        uri = uri.replace('file://', '');
    }

    return uri;
}

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic:

ionic (Ionic CLI) : 4.0.3 (/usr/local/lib/node_modules/ionic)
Ionic Framework : @ionic/angular 4.0.0-beta.2
@angular-devkit/core : 0.7.3
@angular-devkit/schematics : 0.7.3
@angular/cli : 6.1.3
@ionic/ng-toolkit : 1.0.6
@ionic/schematics-angular : 1.0.4

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.1.1, ios 4.5.4

System:

Android SDK Tools : 26.1.1
ios-deploy : 1.9.2
ios-sim : 5.0.13
NodeJS : v10.4.0 (/usr/local/bin/node)
npm : 6.2.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000

Environment:

ANDROID_HOME : /Users/daviddalbusco/Library/Android/sdk

@peterpeterparker
Copy link
Contributor Author

I tried again to use window.Ionic.WebView.convertFileSrc() and it solved my issue this time. Maybe I was facing the issue ionic-team/cordova-plugin-ionic-webview#133 which was solved in cordova-plugin-ionic-webview 2.0.3

Anyhow all good now

@danielsogl
Copy link
Owner

Thanks for the update 👍

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

2 participants