1

I'm creating an Ionic app with camera function. I used for this the doc from ionic-framework Ionic native camera

But I get an error when I tried to display the app on my Android device and click onto the "Take a Picture" button.

Error

"Runtime Error Object(…) is not a function"

"TypeError: Object(…) is not a function at Camera.getPicture"

home.ts


import { Component } from '@angular/core';
import { NavController, PopoverController, ViewController } from 'ionic-angular';
import { UserServiceProvider } from './../../providers/user-service/user-service';
import { Camera, CameraOptions, DestinationType, EncodingType, MediaType } from '@ionic-native/camera/ngx';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
})
export class HomePage {

  constructor(public navCtrl: NavController, public popoverCtrl: PopoverController, private camera:Camera) {}

  myPhoto:any=''

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

    this.camera.getPicture(options).then((imageData)=>{
      this.myPhoto=(<any>window).Ionic.WebView.convertFileSrc(imageData);
    }, (err) => {
      // Error log
    });
  }

  openMoreSetting(event) {
    let popover = this.popoverCtrl.create(PopoverPage);
    popover.present({
      ev: event
    });
  }
}


@Component({
  template: `
    <ion-list>
      <button ion-item>Menu für Settings</button>
    </ion-list>
  `
})
export class PopoverPage {
  constructor(private userServiceProvider: UserServiceProvider,
    private viewCtrl: ViewController) {
  }

  close() {
    this.viewCtrl.dismiss();
  }
}
Hans
  • 49
  • 5
  • I found the solution to the problem ... look here: https://stackoverflow.com/questions/54381062/camera-getpicture-is-not-a-function-in-ionic-3/54396992 – Hans May 06 '19 at 22:45

0 Answers0