Cordova Plugins - Ionic Framework

Hi,
Can i use plain Cordova Plugins with IONICFRAMEWORK ? The Plugin i am trying to use is not available at ngCordova.

Please give me pointers to start like key things to consider.

Plugin :https://github.com/petermetz/cordova-plugin-ibeacon

Thanks in Advance
Kunal D.

Yes, you can use plain cordova plugins. ngCordova are just a collection of AngularJS wrappers.

thanks a lot. any pointers to start? i am a newbie !!! help really appreciated.

thanks again
KD

I’m sorry. I just learned what ibeacon is. So… this allows you to connect to things… right? mostly small battery powered devices, and based on bluetooth wireless communication.

I want to know whether it will it work with any device that have bluetooth or not. So I’m assuming I will need one of those devices in order to use the plugin and make tests and I don’t have one nor the money to buy one ( I’m broke :frowning: ). Conclusion: I can’t help you with this. Sorry :alien:

Ok!!! i ordered devices. I just want to know in general how to use plain cordova plugins without ng wrappers. Say for example i want to use plain version of camera plugin (cordova) how should i implement that. In this way i will get and idea to setup any plugin which is not listed on ngCordova.

Oh. Right. I though I had written that. :laughing:

First: Plugins are available to use after the deviceready event. I think for the Camera plugin you won’t need to worry about this since the action to take a picture or choose one is after a user action and by the time the user does the action, the deviceready event would have happened.

Install the plugin (instead of ionic that could be cordova as well)

ionic plugin add cordova-plugin-camera

Lets say you have a button

<button ng-click="takePicture()">Take picture</button>

and have a controller and want to use the camera plugin without the wrapper:

function MyController($scope) {

  var cameraOptions = { 
    ... 
    quality : 75,
     // the Camera object / plugin is available after deviceready
    destinationType : Camera.DestinationType.DATA_URL, // 
    sourceType : Camera.PictureSourceType.CAMERA
  };
  $scope.takePicture = function() {
    navigator.camera.getPicture(function(dataUrl) {
      console.log(dataUrl);
    }, function(error) {
      console.log(error);
    }, cameraOptions);
  }
} 

youApp.controller('MyController', ['$scope', MyController]);

Be careful: in some case each platform has different options.

Thanks for your help. It helps .