[英]ios app background run
how is it possible that an app like "blitzer.de" enter image description here can run continuously in the background?像“blitzer.de”这样的应用程序如何在此处输入图像描述可以在后台连续运行? enter image description here I´m trying to create an app like this and let it run for approximately 2h in the background while it uses the gps data.
在此处输入图像描述我正在尝试创建一个这样的应用程序,并让它在后台运行大约 2 小时,同时使用 gps 数据。 My researches told me that apple is very strict about background running and will cancel the process in 3 min.
我的研究告诉我,苹果对后台运行非常严格,会在 3 分钟内取消该过程。 Also the fetch will end up in 6 min.
此外,提取将在 6 分钟内结束。 Any help will be appreciated.
任何帮助将不胜感激。
@Johannes @约翰内斯
1) Any App can run in background no more 10 min . 1) 任何应用程序都可以在后台运行不超过10 分钟。 but here is a exceptions for Background Enabled App .
但这里是Background Enabled App 的一个例外。 So you have to enable background mode from
所以你必须从
Capabilities > Background mode功能 > 后台模式
2) Now you have to ask permission for Location Tracking -- Always in App's info.plist 2)现在您必须请求位置跟踪的许可——始终在应用程序的 info.plist 中
NSLocationAlwaysUsageDescription --- I need Location NSLocationAlwaysUsageDescription --- 我需要位置
NSLocationWhenInUseUsageDescription --- I need Location NSLocationWhenInUseUsageDescription --- 我需要位置
privacy - location usage description --- I need Location隐私 - 位置使用说明 --- 我需要位置
3) Now Most important. 3)现在最重要。 the Code
编码
self.locationManager = [[CLLocationManager alloc]init]; // initializing locationManager
_locationManager.desiredAccuracy = kCLLocationAccuracyBest; // setting the accuracy
[self.locationManager requestAlwaysAuthorization];
self.locationManager.delegate = self;
if([self.locationManager respondsToSelector:@selector(allowsBackgroundLocationUpdates)]) {
[self.locationManager setAllowsBackgroundLocationUpdates: YES];
}
self.locationManager.distanceFilter = 50 ; //
self.locationManager.activityType=CLActivityTypeAutomotiveNavigation;
[self.locationManager startUpdatingLocation];
[self.locationManager setPausesLocationUpdatesAutomatically:NO];
4). 4)。 setPausesLocationUpdatesAutomatically:NO Will allow your app to run continuously.
setPausesLocationUpdatesAutomatically:NO 将允许您的应用程序连续运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.