5

I am using camera plugin to click picture in ionic app, but i am getting the following error

OrdercancelPage.html:24 ERROR TypeError: Object(...) is not a function
at Camera.getPicture (index.js:125)
at OrdercancelPage.webpackJsonp.444.OrdercancelPage.getphoto (ordercancel.ts:24)
at Object.eval [as handleEvent] (OrdercancelPage.html:24)
at handleEvent (core.js:13547)
at callWithDebugContext (core.js:15056)
at Object.debugHandleEvent [as handleEvent] (core.js:14643)
at dispatchEvent (core.js:9962)
at core.js:10587
at HTMLButtonElement.<anonymous> (platform-browser.js:2628)
at t.invokeTask (polyfills.js:3)

My code is

getphoto(){
this.camera.getPicture({
  quality: 100,
  destinationType: this.camera.DestinationType.FILE_URI,
  encodingType: this.camera.EncodingType.JPEG,
  mediaType: this.camera.MediaType.PICTURE,
  sourceType: this.camera.PictureSourceType.CAMERA,
  targetWidth: 1024,
  targetHeight: 720
}).then((imageData) => {
  // imageData is a base64 encoded string
  this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
  console.log(err);
});

}

I am using the plugin

import {   Camera } from '@ionic-native/camera/ngx';
4
  • same on my end If you manage to solve it please tell me your solution
    – honeyspoon
    Jan 26, 2019 at 22:09
  • 2
    Remove Camera plugin First and then Do 1) ionic cordova plugin add cordova-plugin-camera 2) npm install @ionic-native/[email protected] Jan 27, 2019 at 6:12
  • Hope you added it in provider array in app.module.ts Jan 27, 2019 at 8:30
  • Did you properly install Camera plugin? Did you follow the docs? Jan 28, 2019 at 3:18

2 Answers 2

10

just remove your plugin and install-

npm install @ionic-native/[email protected] 

This will solve your problem

1
  • I am getting error in ionic3 after taking picture with camera Error capturing image.. Any solution for that ? It works fine with gallery selection. Sep 16, 2020 at 5:14
6

The problem was that , i was using plugin version 5.0.0 . I downgraded to version 4.x.x using package.json and it worked fine without using ngx to import.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.