3

I'm trying to open PDF file in ionic with @ionic-native/file-opener and getting cordova problem.

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

How can I solve it?

Melchia
  • 22,578
  • 22
  • 103
  • 117
liskior
  • 67
  • 2
  • 12

3 Answers3

5

The only way to make cordova available is run the platform browser.

$ ionic cordova run browser 
Melchia
  • 22,578
  • 22
  • 103
  • 117
  • `ionic cordova run browser > cordova platform add browser --save Using cordova-fetch for cordova-browser@4.1.0 Adding browser project... Project already exists! Delete and recreate` – liskior Apr 22 '18 at 01:56
  • i get this mistake:( – liskior Apr 22 '18 at 01:59
2

Are you running in a browser or emulator? You can use the Ionic CLI to run in an emulator, like so:

ionic cordova run android

If you have Cordova and the Android SDK set up, it should launch the emulator.

Tony Laidig
  • 1,048
  • 2
  • 11
  • 33
2

Copying @AjayGupta's answer from this thread:

If you want the plugin to work for the browser you should add platform browser and run it:

ionic cordova platform add browser and run it:

ionic cordova run browser instead of ionic serve.

LordColus
  • 417
  • 1
  • 5
  • 12
  • `> cordova platform add browser --save Using cordova-fetch for cordova-browser@4.1.0 Adding browser project... Project already exists! Delete and recreate [ERROR] Exception: ` – liskior Apr 23 '18 at 00:27
  • Try using `ionic platform add browser` instead of `cordova add browser`? – LordColus Apr 23 '18 at 00:29
  • Also, make sure there's not already a browser project at ~/platforms/browser ("~" being the root directory of your project). If there is, delete it and re-run the command. – LordColus Apr 23 '18 at 00:32
  • there is no platforms/browser and `ionic platform add browser` give `The platform command has been renamed. To find out more, run: ionic cordova platform --help` – liskior Apr 23 '18 at 00:37