Ionic-native: Still getting Cordova not available error even with Camera mock class

Created on 14 May 2017  路  1Comment  路  Source: ionic-team/ionic-native

I followed the guide for using the camera plugin in the browser. In my app.module.ts file I have:

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

I am declaring a mock class like so:

export class CameraMock extends Camera {
  getPicture(options) {
    return new Promise((resolve, reject) => {
      resolve('base64-data');
    });
  }
}

And one item in my array of providers is { provide: Camera, useClass: CameraMock }.

When I run my project in the browser, however, I still receive this message: Native: tried calling Camera.getPicture, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator. When I try ionic cordova run browser instead, I am told that the camera plugin does not support the browser platform.

Please let me know what I'm doing wrong. Thanks!

bug need to reproduce

>All comments

I've been having the same problem :-(

The problem seems that ocurrs only with Camera. I tested with BarCodeScann and worked fine.

Was this page helpful?
0 / 5 - 0 ratings