Skip to content

Latest commit

 

History

History
117 lines (95 loc) · 3.06 KB

PLUGINS.md

File metadata and controls

117 lines (95 loc) · 3.06 KB

Plugins

Here are the Cordova plugins you may access by loading vue-cordova plugin in your VueJS app.

Device Plugin

Describes the device's hardware and software (NPM)

Device information is made available in Vue.cordova.device.

// Vue.cordova.device example
{
  "device": {
    "cordova": "4.2.1",
    "model": "x86_64",
    "platform": "iOS",
    "uuid": "XXX-XXX-XXX",
    "version": "9.3",
    "manufacturer": "Apple",
    "isVirtual": true,
    "serial": "unknown"
  }
}

Camera Plugin

API to access the device's camera (NPM)

The camera and its API is made available in Vue.cordova.camera. The global options in Camera are also present there. (don't mind the uppercase "C")

// Vue.cordova.camera content
{
  "camera": {
    "DestinationType": {
      "DATA_URL": 0,
      "FILE_URI": 1,
      "NATIVE_URI": 2
    },
    ...
  }
}

// take a picture
Vue.cordova.camera.getPicture((imageURI) => {
  window.alert('Photo URI : ' + imageURI)
}, (message) => {
  window.alert('FAILED : ' + message)
}, {
  quality: 50,
  destinationType: Vue.cordova.camera.DestinationType.FILE_URI
})

Geolocation Plugin

API to access the device's location (NPM)

The GPS is made available in Vue.cordova.geolocation. You may then access the current device's location or watch the current position. See the original plugin's docs.

// get current location
Vue.cordova.geolocation.getCurrentPosition((position) => {
  window.alert('Current position : ' + position.coords.latitude + ',' + position.coords.longitude)
}, (error) => {
  window.alert('FAILED Error #' + error.code + ' ' + error.message)
}, {
  timeout: 1000,
  enableHighAccuracy: true
})

Contacts Plugin

API to access the device's contact database (NPM)

The contacts database is made available in Vue.cordova.contacts. You may then find a contact or create a new one.

// find contacts
Vue.cordova.contacts.find(['displayName'], (contacts) => {
  window.alert('Contacts found : ' + contacts.length)
}, (error) => {
  window.alert('FAILED : ' + error.code)
})

DBMeter Plugin

Plugin to get decibel levels using the microphone (NPM)

// start listening 
Vue.cordova.dbmeter.start(function(dB){
  // success
  console.log(dB);
}, function(e){
  // error
  console.log('code: ' + e.code + ', message: ' + e.message);
});

Or, original plugin places DBMeter in global scope

DBMeter.start(function(dB){
  console.log(dB);
}, function(e){
  console.log('code: ' + e.code + ', message: ' + e.message);
});