[英]ios app background run
@約翰內斯
1) 任何應用程序都可以在后台運行不超過10 分鍾。 但這里是Background Enabled App 的一個例外。 所以你必須從
2)現在您必須請求位置跟蹤的許可——始終在應用程序的 info.plist 中
NSLocationAlwaysUsageDescription --- 我需要位置
NSLocationWhenInUseUsageDescription --- 我需要位置
隱私 - 位置使用說明 --- 我需要位置
3)現在最重要。 編碼
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)。 setPausesLocationUpdatesAutomatically:NO 將允許您的應用程序連續運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.