私はAngularJSとIonicの新機能です。私は、バックグラウンドでデバイスのGPS位置を収集するIonic(バージョン1)のアプリケーションを構築しています。私はこの目的のためにcordova-plugin-mauron85-background-geolocationプラグインを使用しようとしています。しかし、私はエラーにUncaught ReferenceError: backgroundGeolocation is not defined.
Uncaught ReferenceError:backgroundGeolocationが定義されていませんcordova-plugin-mauron85-background-geolocation
マイapp.js
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'firebase', 'ngMaterial'])
.factory('BackgroundGeolocationService', ['$q', '$http', function ($q, $http) {
var callbackFn = function(location) {
$http({
//request options to send data to server
});
backgroundGeolocation.finish();
},
failureFn = function(error) {
console.log('BackgroundGeoLocation error ' + JSON.stringify(error));
},
//Enable background geolocation
start = function() {
//save settings (background tracking is enabled) in local storage
window.localStorage.setItem('bgGPS', 1);
//...........ERROR IS ON THE FOLLOWING LINE.........
backgroundGeolocation.configure(callbackFn, failureFn, {
desiredAccuracy: 10,
stationaryRadius: 20,
distanceFilter: 30,
locationService: 'ANDROID_DISTANCE_FILTER',
debug: false,
stopOnTerminate: false
});
backgroundGeolocation.start();
};
return {
start: start,
// Initialize service and enable background geolocation by default
init: function() {
var bgGPS = window.localStorage.getItem('bgGPS');
if (bgGPS == 1 || bgGPS == null) {
start();
}
},
// Stop data tracking
stop: function() {
window.localStorage.setItem('bgGPS', 0);
backgroundGeolocation.stop();
}
}
}])
.run(function($ionicPlatform, BackgroundGeolocationService) {
$ionicPlatform.ready(function() {
BackgroundGeolocationService.init();
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
cordova.plugins.Keyboard.disableScroll(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
を取得しています私はここで何をしないのですか?
Cordovaデバイス準備完了イベントが発生し、プラグインコードを配置しました。内部プラットフォームの準備機能? – Gandhi
@ガンジー私は$ ionicPlatform.readyの中の工場に電話しました –
あなたはchrome inspect deviceオプションを使ってデバッグすることができましたか?私はあなたにこれについてのより多くの情報を与えると思います – Gandhi