Ionic/Cordova: How to integrate Cordova Plugins into existing Ionic project?

后端 未结 7 2388
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 07:05

I have an Ionic project where I need the Cordova Camera plugin (which I now installed successfully). But in my project the Camera API is still not available, i.e. I get error th

7条回答
  •  天涯浪人
    2021-02-19 07:17

    Follow these steps:

    1. Include ngCordova before cordova.js

    You can found the same description in the docs.

    
    
    

    2. Add your plugin on the command line

    You can find this step in the docs in the section of your specific plugin.

    ionic plugin add org.apache.cordova.camera
    

    3. Remember that cordova is not available while working in the browser

    So when using the $cordovaCamera.getPicture the library is calling internally navigator.camera.getPicture which is not available when developing in the desktop browser. Further reading

    The ngCordova / Ionic team is currently working on mocks you can use to avoid problems like that.


    You can download ngCordova here: http://ngcordova.com/docs/install/


    Update: There is Ionic Native now, it's like ngCordova but for ES6 and TypeScript.

提交回复
热议问题