【问题标题】:Proper iOS Background Location Updates正确的 iOS 后台位置更新
【发布时间】:2011-04-29 00:00:30
【问题描述】:

在我的应用程序运行时,使用苹果 CLLocationManager 的位置更新工作正常。我决定实现苹果文档中描述的 MonitorSignificantLocationChanges 方法。

这是我的 applicationDidEnterBackground 方法:

- (void)applicationDidEnterBackground:(UIApplication *)application {

// Switch to significant location change events monitoring
[self.viewController.locationController.locationManager stopUpdatingLocation];
[self.viewController.locationController.locationManager startMonitoringSignificantLocationChanges];

我遇到的问题是,无论我是否 startMonitoringSignificantLocationChanges,即使应用程序已从多任务栏中删除,我的应用程序仍会向 iOS 报告它正在使用位置更新。只需安装应用程序而无需运行它就足以让 iOS 在屏幕右上角显示位置图标,并且手机开始耗尽电池电量。我不知道如何在按下主页按钮时正确停止位置更新以及如何正确启动重大变化监控服务。

如果我可以提供任何其他有用的详细信息,请告诉我。

【问题讨论】:

    标签: iphone ios gps core-location multitasking


    【解决方案1】:

    我认为这是一个错误。我设法通过删除应用程序并重置位置警告来解决此问题。之后,如果我再次安装该应用程序,位置箭头无论如何都不会显示,即使我允许该应用程序的位置并关闭它

    【讨论】:

    • 我尝试了相同的步骤,但这并没有解决我的问题。你的意思是这是一个 iOS 错误吗?
    【解决方案2】:
    [self.viewController.locationController.locationManager startMonitoringSignificantLocationChanges];
    

    您已经开始了重要的位置更新,这将跟踪用户的位置。这也是位置管理器服务之一。在您停止此服务或从设备中删除您的应用之前,您将不断在右上角看到 GPS 图标。

    要停止使用此服务,

    [self.viewController.locationController.locationManager stopMonitoringSignificantLocationChanges];
    

    一旦您停止了重要的位置更新,GPS 图标就会消失...

    请参考this,在此检查获取用户当前位置

    希望这对你有帮助....

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-03
      • 1970-01-01
      • 2017-12-16
      • 2018-03-11
      • 1970-01-01
      • 2013-07-31
      相关资源
      最近更新 更多