I`m using Ionic as a mobile app and testing my things in combination with the phonegap developer app.
I always get an 'undefined' for the backgroundgeolocation
plugin when using phonegap developer app and executing 'phonegap serve'
I've added the cordova plugin:
cordova plugin add https://github.com/christocracy/cordova-plugin-background-geolocation.git
I adapted config.xml and included the plugin.
<gap:plugin name="org.transistorsoft.cordova.background-geolocation" />
How do I use the backgroundgeolocation
plugin in combination with the 'phonegap serve' command?
This is what I tried:
.controller('DashCtrl', function($scope,$cordovaBackgroundGeolocation,$ionicPlatform,$cordovaGeolocation,$window,$timeout) {
document.addEventListener("deviceready", function () {
$ionicPlatform.ready(function() {
$window.navigator.geolocation.getCurrentPosition(function(location) {
console.log('Location from Phonegap');
});
$timeout(function() {
var bgGeo = $window.plugins.backgroundGeoLocation;
alert(bgGeo);
var callbackFn = function(location){
alert('YEEEAH'+JSON.stringify(location));
};
var failureFn = function(error){
alert('Geolocation Error');
};
bgGeo.configure(callbackFn, failureFn, {
desiredAccuracy: 0,
stationaryRadius: 5,
distanceFilter: 30,
debug: true
});
alert('start');
bgGeo.start();
alert('started');
},5000);
});
}, false);
});