Search code examples
cordovaionic-frameworkcordova-plugins

How do I integrate Native Cordova Plugin in Ionic Framework? camerapicturebackground


I've been trying to install a custom cordova plugin (not available in the ngCordova library) in my Ionic project which will enable me to take a picture with no user input on Android:

camerapicturebackground

I've been struggling with integrating this properly into my Ionic App, and am not sure how to:

a) Implement deviceready as per Cordova documentation:

    document.addEventListener("deviceready", yourCallbackFunction, false);

b) Call function within Ionic without app crashing.


Solution

  • Instead of deviceready on the device, try using ionic's built in ready method, that fires when Cordova, Angular, and Ionic are ready.

    ionic.Platform.ready(function(){
      //do plugin stuff here
    });
    

    http://ionicframework.com/docs/api/utility/ionic.Platform/