【发布时间】:2015-02-19 08:30:56
【问题描述】:
我编写在后台运行的应用程序(用于自动)并使用 gps (startUpdatingLocations)。 当然,我知道 plist 中的 bgModes 和电池消耗。 而且我需要精确的 GPS - 高精度。
应用程序正常工作,直到另一个 gps-app 没有进入前台。 一段时间后,由于用户打开另一个导航程序,iOs 系统终止了我的程序。 我可以通知用户“对不起,但操作系统决定终止我的应用程序。重新启动它”。 但这并不好。
那么,这是一种重启程序的方法吗(在后台)???
绝对标准的代码。没什么特别的
class "gps"
-(id)init
{
.....
locMan = [[CLLocationManager alloc] init];
locMan.delegate=self;
locMan.distanceFilter = kCLDistanceFilterNone;
locMan.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
.....
}
-(void)start
{
..............
if(sysVer>=8.0)
{
[locMan requestAlwaysAuthorization];
}
[locMan startUpdatingLocation];
if(sysVer>=6)
{
locMan.pausesLocationUpdatesAutomatically=NO;
}
............
}
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
... processing
}
-(void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
... processing
}
【问题讨论】:
标签: ios background gps location