Ionic-native: Camera plugin doesn't work in Browser

Created on 5 Aug 2016  Â·  9Comments  Â·  Source: ionic-team/ionic-native

The Camera plugin claims support for the Browser platform in the documentation, but when I attempt to use it in a browser (Chrome v52, OS X 10.11.5) it prints this to console

Native: tried calling Camera.getPicture, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
navigator

It works just fine when I build and run on an Android phone. I'm just trying to get media from the gallery on phones, and from the file system in browser.

Is this just a mistake in documentation, or an actual bug?

question

Most helpful comment

@josx
ionic serve runs your app as a website (meaning it doesn't have any Cordova capabilities)
ionic run browser runs your app in the Cordova browser platform, which will inject cordova.js and any plugins that have browser capabilities

All 9 comments

Did you add the browser platform and run the command "ionic run browser" ?

On Aug 5, 2016 5:51 PM, "Louis Orleans" [email protected] wrote:

The Camera plugin claims support for the Browser platform in the
documentation, but when I attempt to use it in a browser (Chrome v52, OS X
10.11.5) it prints this to console

Native: tried calling Camera.getPicture, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
navigator

It works just fine when I build and run on an Android phone. I'm just
trying to get media from the gallery on phones, and from the file system in
browser.

_Is this just a mistake in documentation, or an actual bug?_

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/driftyco/ionic-native/issues/403, or mute the thread
https://github.com/notifications/unsubscribe-auth/ANJ8dBQABVHuklJlfHADCCMHMZvwwiqoks5qc7BMgaJpZM4JeFwU
.

I didn't realize that there was a difference between ionic run browser and ionic serve. When I use that, it works! Thanks!

Do you know of any plans to get a live-reload system working with run, or to get ionic-native to work with serve?

You can use live reload with Ionic Native.

First install all the plugins you need, run the livereload, then you can do
any changes to your code and see it in effect immediately on the
device/emulator.

On Fri, Aug 5, 2016 at 7:24 PM, Louis Orleans [email protected]
wrote:

I didn't realize that there was a difference between ionic run browser
and ionic serve. When I use that, it works!

Do you know of any plans to get a live-reload system working with run, or
to get ionic-native to work with serve?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/driftyco/ionic-native/issues/403#issuecomment-237988273,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ANJ8dIRMPlni8CnenVu9a6VLgrSyaumMks5qc8Y5gaJpZM4JeFwU
.

@ihadeed which is the difference between ionic serve and ionic run browser?

@josx
ionic serve runs your app as a website (meaning it doesn't have any Cordova capabilities)
ionic run browser runs your app in the Cordova browser platform, which will inject cordova.js and any plugins that have browser capabilities

Great suggestion by @ihadeed Worked like a charm. Just a suggestion: if ionic run browser doesn't work for you, try:

ionic cordova run browser

If the terminal prompts

[ERROR] native-run was not found on your PATH

Then install npm i -g native-run

and try ionic cordova run browser. It should work.

Great suggestion by @ihadeed Worked like a charm. Just a suggestion: if ionic run browser doesn't work for you, try:

ionic cordova run browser

If the terminal prompts

[ERROR] native-run was not found on your PATH

Then install npm i -g native-run

and try ionic cordova run browser. It should work.

Or you could do it by adding:
ionic cordova run browser --native-run=false

Hey guys, I'm working in an ionic 5 capacitor project and I can't find a workaround for this, any update on how to use this plugin on browser?

Have same problem @frederickjjoubert

Was this page helpful?
0 / 5 - 0 ratings