在iOS上的后台获取GPS数据

时间:2013-08-09 12:09:04

标签: ios xcode background gps

我知道其他人已经问过这个问题了,我已经阅读了所有的回复,但我的代码仍然没有用,而且我不知所措。

我正在尝试做的是在应用程序在后台运行时收到有关位置更改的通知。

这是我到目前为止所拥有的:

在我的AppDelegate.m中:

- (void)applicationDidEnterBackground:(UIApplication *)application {
    NSLog(@"Background");

    [self.viewController.locationManager startMonitoringSignificantLocationChanges];
}

在我的ViewController.m中:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {

    NSLog(@"didUpdateToLocation");
    NSLog(@"newLocation: %@", newLocation);

}

当应用程序位于前台时,此功能正常,但不在后台。

我触发了GPS更改,我正在使用iPhone模拟器切换位置。这可能不会引发背景事件吗?

非常感谢任何帮助。

谢谢,

布赖恩

0 个答案:

没有答案
相关问题