我的位置服务应用程序运行后台进程工作但是10分钟后应用程序关闭。我正在使用以下步骤
1)在.plist文件中手动添加密钥
<key>Required background modes</key>
<array>
<string>App registers for location updates</string>
</array>
2)代码是
self.locationManager = [[CLLocationManager alloc] init];
[locationManager startUpdatingLocation];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSString *latVal = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.latitude];
NSString *lonVal = [[NSString alloc] initWithFormat:@"%f", newLocation.coordinate.longitude];
}
我需要经常更新后台流程而不关闭申请,请帮帮我。
答案 0 :(得分:0)
在didFinishLaunchingWithOptions
我们这个。
self.locationManager = [[CLLocationManager alloc] init];
[locationManager startMonitoringSignificantLocationChanges];
locationManager.delegate = self;
这将确保您的应用程序即使被杀死也会被调用。