getPicture() fails with Ionic

Bug Report


What is expected to happen?

I expected camera plugin to return BASE64 data so I can send it and save it on server.

What does actually happen?

On device, fails with error message:

Cannot read property ‘present’ of undefined

Same thing happens if I use CAMERA or PHOTOLIBRARY as sourceType

Command or Code

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

injected in constructor
constructor(public camera: Camera) { }

and then used in my upload() method

let options = {
      quality: 100,
      saveToPhotoAlbum: false,
      correctOrientation: false
}; => {
let base64Image = 'data:image/jpeg;base64,' + imageData;
    }).catch(err => {

Environment, Platform, Device

Not depending on device, happened on multiple devices wit different versions, eg.
Xiaomi Mi 8 - Android 10
Samsung Galaxy A3 - Android 6

Version information

Ionic 5.4.16
Cordova: 9.0.0 (cordova-lib@9.0.1)
cordova-plugin-camera 4.1.0 “Camera”

Hard to know what the issue is from just that. Can you provide a demo/sample app?

Or can you break it down further to see where the issue happens?

Cannot read property ‘present’ of undefined

This doesn’t really seem to be an issue with the camera, so more detail is required.

Hello, our app is here (I work with author of this topic).

You can get the error on settings page while editing profile. (pages/settings/profile/
You can also freely register account and try it out :slight_smile:

Thanks, man :wink:

I think it’s a bad idea to keep references to loading components in controller properties. It invites reuse bugs. However, if you are going to do it, you need to be really sure that they’re valid before you interact with them. Specifically looking at the profile page, although I stopped looking when I found this. May be others.