Here are the Cordova plugins you may access by loading vue-cordova
plugin in your VueJS app.
- Device Plugin
- Camera Plugin
- Geolocation Plugin
- Contacts Plugin
- [DBMeter Plugin] (#dbmeter-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"
}
}
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
})
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
})
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)
})
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);
});