Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 开始工作+;ngCordova+;背景地理定位_Ios_Angularjs_Geolocation_Ionic Framework_Ngcordova - Fatal编程技术网

Ios 开始工作+;ngCordova+;背景地理定位

Ios 开始工作+;ngCordova+;背景地理定位,ios,angularjs,geolocation,ionic-framework,ngcordova,Ios,Angularjs,Geolocation,Ionic Framework,Ngcordova,应用程序的目标:获取每次移动的地理位置,并在应用程序位于前台和后台时记录位置 我已经尝试了这么多的代码和组合,但我不能设法让它工作(从现在起2天…) 经典的地理定位(getCurrentPosition)工作正常,但当我们关闭应用程序时,后台地理定位启动,但什么也没有发生。。。函数“callbackFn”从未被激发 我在IOS上测试,xcode>功能音频和位置为后台活动激活。我还制作了插件中给出的jQuery示例,因此我看到它可以工作,但从未使用过ionic/angularjs 以下是处理后台的

应用程序的目标:获取每次移动的地理位置,并在应用程序位于前台和后台时记录位置

我已经尝试了这么多的代码和组合,但我不能设法让它工作(从现在起2天…)

经典的地理定位(getCurrentPosition)工作正常,但当我们关闭应用程序时,后台地理定位启动,但什么也没有发生。。。函数“callbackFn”从未被激发

我在IOS上测试,xcode>功能音频和位置为后台活动激活。我还制作了插件中给出的jQuery示例,因此我看到它可以工作,但从未使用过ionic/angularjs

以下是处理后台的当前控制器:

.controller('TestCtrl', function($scope, $timeout, $cordovaBackgroundGeolocation, $ionicPlatform, $window)
{
$scope.lat_geo = "loading lat...";
$scope.long_geo = "loading long...";


//-- Geolocal launch
var options = {
    enableHighAccuracy : false,
    desiredAccuracy: 0,
    stationaryRadius: 1,
    distanceFilter: 5,
    notificationTitle: 'Background tracking', // <-- android only, customize the title of the notification
    notificationText: 'ENABLED', // <-- android only, customize the text of the notification
    activityType: 'AutomotiveNavigation',
    debug: true, // <-- enable this hear sounds for background-geolocation life-cycle.
    stopOnTerminate: false // <-- enable this to clear background location settings when the app terminates
};

$ionicPlatform.ready(function()
{
    console.log("[IONIC PLATFORM IS NOW READY]");

    //-- First launch a basic geolocalisation to get user acceptance of geosharing ;)
    navigator.geolocation.getCurrentPosition(function(location) {
            console.log('[GEOLOCAL JS1] Location from Phonegap');
    },
    function (error){
            console.log('[GEOLOCAL JS1] error with GPS: error.code: ' + error.code + ' Message: ' + error.message);
    },options);

    //-- test adaptation depuis l'app jquery
    var callbackFn = function(location) {
            console.log('[BackgroundGeoLocation] Update callback:  ' + location.latitude + ',' + location.longitude);
    };

    var failureFn = function(error) {
            console.log('[BackgroundGeoLocation] Error: '+error);
    };

    $cordovaBackgroundGeolocation.configure(callbackFn, failureFn, options);

    // Turn ON the background-geolocation system.  The user will be tracked whenever they suspend the app.
    $cordovaBackgroundGeolocation.start();

    //-- Just a timeout to retreive long / lat
    $timeout(function()
    {
        navigator.geolocation.getCurrentPosition(function(location)
        {
            console.log('[GEOLOCAL JS3] Location from Phonegap');
            startPos = location;
            $scope.$apply(function () {
                $scope.lat_geo = startPos.coords.latitude;
                $scope.long_geo = startPos.coords.longitude;
            });
            console.log("[GEOLOCAL BASIC] OK this time :)");
        },
        function (error){
            console.log('[GEOLOCAL JS3] error with GPS: error.code: ' + error.code + ' Message: ' + error.message);
        },options);
    }, 3000);

});
//-- End Geolocal
})
.controller('TestCtrl',函数($scope、$timeout、$cordovaBackgroundGeolocation、$ionicPlatform、$window)
{
$scope.lat_geo=“加载纬度…”;
$scope.long_geo=“加载长…”;
//--地球本地发射
变量选项={
EnableHighAccurance:错误,
所需精度:0,
静止半径:1,
距离过滤器:5,
notificationTitle:“背景跟踪”,我读了这篇文章

我知道你应该把你的代码放到

document.addEventListener(“deviceready”,函数(){…});


你找到解决方案了吗?

你肯定不想在bg中使用std Cordova地理定位插件,它会很快耗尽电池

我是爱奥尼亚的底层背景地理定位插件的作者。我创建了一个新的基于爱奥尼亚的SampleApp


嗨,我确实尝试过用DeviceRady进行封装,但没有成功。你可以在controller.js上看到我在第70行的评论中提到它。现在我只是放弃了使用这个bglocation,因为我没有时间花在它上面,可能在几个月后。RTFM,这是有明确记录的。那个Android版本已经不受支持了,顺便说一句,它吃了b就像野餐时的蚂蚁一样。我不建议将其用于生产应用程序,特别是如果你想让你的用户喜欢你的话。是的,我找到了。不过,如果你在代码示例中陈述一些对平台根本不起作用的事情,那就太好了。不要详细地写它,并在
行为的最后一章中提到它ode>有些东西实际上根本不起作用。无论如何,我只需要每隔,比如说,30分钟检查一次位置。您使用的版本不再受支持(并且至少已经6个月不受支持)。如果您有进一步的问题,新回购协议就在这里,您最好直接在回购协议上提出问题。