[英]iOS 7 Significant location change launch after termination
當新的位置數據到達iOS 6而非iOS 7時,我的應用終止后會自動喚醒。
[[UIApplication sharedApplication] setBackgroundRefreshStatus]
是UIBackgroundRefreshStatusAvailable
。
在Info.plist
我將UIBackgroundModes
設置為值“ location”。
CLLocationManager
以這種方式啟動:
- (void) start {
if (locationManaher == nil) {
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
}
[locationManager startMonitoringSignificantLocationChanges]
}
- (void) locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocationCoordinate2D newCoordinate = newLocation.coordinate;
CLLocationCoordinate2D oldCoordinate = oldLocation.coordinate;
if (newCoordinate.latitude == oldCoordinate.latitude && newCoordinate.longitude == oldCoordinate.longitude) return;
float distance = [newLocation distanceFromLocation:oldLocation];
if (distance < distanceFilter) {
//send to server
}
}
有人知道哪里有問題嗎?
這是7.0 iOS功能,如果用戶手動關閉應用程序(通過主頁按鈕雙擊),則該應用程序不會在位置更改時觸發。
不建議使用locationManager:didUpdateToLocation:fromLocation:
方法,從iOS 6開始生效。您現在應該使用locationManager:didUpdateLocations:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.