Skip to content

Ionic 3 Camera not working in IPhone ios 11 #2020

@mqasem92

Description

@mqasem92

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

Current behavior:
I'm trying to build feature in my application that take photo from the camera and preview the taken photo in the <img [src]="" />

The camera'll open fine, but when try to preview the image nothing appear.

Notes:

  • It's working in the android devices
  • The preview shown when get photos from the mobile gallery.
  • I'm testing my app using Ionic View.

Expected behavior:
Preview the image taken from the Camera

Steps to reproduce:

Related code:

public photos: any = [];

constructor(public navCtrl: NavController,
    public navParams: NavParams,
    public actionSheetCtrl: ActionSheetController,
    private camera: Camera) {

  }

takePicture() {
    
    const options: CameraOptions = {
      quality: 100,
      destinationType: this.camera.DestinationType.DATA_URL,
      encodingType: this.camera.EncodingType.JPEG,
      mediaType: this.camera.MediaType.PICTURE
    }

    this.camera.getPicture(options).then((imageData) => {

      //add photo to the array of photos
      this.base64Image = "data:image/jpeg;base64," + imageData;
      this.addPhoto(this.base64Image);

    }, (error) => {
      console.debug("Unable to obtain picture: " + error, "app");
      console.log(error);
    });
  }

addPhoto(photo) {
      this.photos.push(photo);
      this.photos.reverse();
  }

 <ion-grid>
      <ion-row>
        <ion-col col-6 *ngFor="let photo of photos; let id = index">
          <ion-card>
            <img [src]="photo" *ngIf="photo" (click)="openPhotoActionSheet(id)" />
          </ion-card>
        </ion-col>
      </ion-row>
    </ion-grid>

Other information:
@ionic/cli-utils : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.7.0

System:

Node : v6.10.3
npm  : 3.10.10
OS   : Windows 10

Misc:

backend : legacy

package.json info:

{
    "name": "ionic-hello-world",
    "author": "mqasem",
    "homepage": "http://xxxx.com/",
    "private": true,
    "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
    },
    "dependencies": {
        "@angular/common": "^4.4.3",
        "@angular/compiler": "^4.4.3",
        "@angular/compiler-cli": "^4.4.3",
        "@angular/core": "^4.4.3",
        "@angular/forms": "^4.4.3",
        "@angular/http": "^4.4.3",
        "@angular/platform-browser": "^4.4.3",
        "@angular/platform-browser-dynamic": "^4.4.3",
        "@angular/platform-server": "4.0.2",
        "@ionic-native/camera": "^4.3.0",
        "@ionic-native/core": "^4.2.1",
        "@ionic-native/device": "^4.2.1",
        "@ionic-native/splash-screen": "^3.4.2",
        "@ionic-native/status-bar": "^3.4.2",
        "@ionic/storage": "^2.0.1",
        "@ngx-translate/core": "^8.0.0",
        "@ngx-translate/http-loader": "^2.0.0",
        "angular2-google-maps": "^0.17.0",
        "cordova-android": "^6.2.3",
        "cordova-ios": "^4.4.0",
        "cordova-plugin-camera": "^2.4.1",
        "cordova-plugin-compat": "^1.2.0",
        "cordova-plugin-console": "^1.0.5",
        "cordova-plugin-device": "^1.1.4",
        "cordova-plugin-ionic-webview": "^1.1.8",
        "cordova-plugin-splashscreen": "^4.0.3",
        "cordova-plugin-statusbar": "^2.2.1",
        "cordova-plugin-whitelist": "^1.3.1",
        "cordova-plugin-x-toast": "^2.5.2",
        "cordova-sqlite-storage": "^2.0.4",
        "ionic-angular": "^3.7.0",
        "ionic-native": "2.9.0",
        "ionic-plugin-keyboard": "^2.2.1",
        "ionicons": "3.0.0",
        "phonegap-plugin-barcodescanner": "^6.0.8",
        "rxjs": "^5.4.3",
        "sw-toolbox": "3.4.0",
        "zone.js": "^0.8.17"
    },
    "devDependencies": {
        "@ionic/app-scripts": "^3.0.0",
        "typescript": "~2.2.1"
    },
    "cordovaPlugins": [
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "ionic-plugin-keyboard"
    ],
    "cordovaPlatforms": [],
    "description": "ionicTemplate2: An Ionic project",
    "cordova": {
        "plugins": {
            "cordova-plugin-console": {},
            "cordova-plugin-device": {},
            "cordova-plugin-splashscreen": {},
            "cordova-plugin-statusbar": {},
            "cordova-plugin-whitelist": {},
            "cordova-plugin-x-toast": {},
            "ionic-plugin-keyboard": {},
            "phonegap-plugin-barcodescanner": {
                "CAMERA_USAGE_DESCRIPTION": " "
            },
            "cordova-plugin-ionic-webview": {},
            "cordova-sqlite-storage": {},
            "cordova-plugin-compat": {}
        },
        "platforms": [
            "android",
            "ios"
        ]
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions