繁体   English   中英

Cordova-ionic应用程序在后台进行地理位置定位-Android和iOS

[英]cordova-ionic app take geolocation in background - android and ios

我想使用cordova和ionic来构建一个能够提供地理位置的应用程序。 根据我的研究,当应用程序在后台运行时,提供有关地理位置的信息存在一些问题。 您能提供任何有关如何解决此问题的提示或建议吗? 谢谢你:D

当然,使用此插件可以进行背景地理定位: cordova-plugin-background-geolocation

添加ngCordova以通过AngularJS包装器与插件交互。

ngCordovacordova-plugin-background-geolocation的示例(来自ngCordova Docs的示例):

module.controller('MyCtrl', function($scope, $cordovaBackgroundGeolocation) {

  var options = {
    // https://github.com/christocracy/cordova-plugin-background-geolocation#config
  };

  document.addEventListener("deviceready", function () {

    // `configure` calls `start` internally
    $cordovaBackgroundGeolocation.configure(options)
    .then(
      null, // Background never resolves
      function (err) { // error callback
        console.error(err);
      },
      function (location) { // notify callback
        console.log(location);
      });


    $scope.stopBackgroundGeolocation = function () {
      $cordovaBackgroundGeolocation.stop();
    };

  }, false);
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM