2013-10-08 28 views
0

我工作的一個跟蹤應用中,我使用位置管理服務和位置更新在後臺模式下不工作的iOS 7.0中的iPhone4s和iPhone5的同時,iPhone在理想

集desiredAccuracy = kCLLocationAccuracyNearestTenMeters

和distanceFilter = 60.0。

我想給背景支持。對於我

一套應用程序註冊了位置更新,從網絡

在我的info.plist

應用軟件下載的內容。我把

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; 

這個代碼在didFinishLaunchingWithOptions方法。

我也用這個方法調用startUpdatingLocation位置管理方法

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 

在iOS的7這一切工作,iPhone4的

,但我在的iPhone4S和iPhone5的另外兩個設備在設備時,設備理想的情況是,應用程序在後臺,導航符號消失,我的位置數據沒有在服務器上更新。

當手機是理想的,當我開始我的應用程序它不在後臺我的應用程序從登錄屏幕開始。

因此背景位置更新不適用於iOS5的iPhone5和iPhone4S。

請爲我提供解決方案。

我的申請是爲了追蹤目的,如果我沒有得到更新的位置,所以它是無用的。

+0

添加此方法在你需要得到在後臺您的位置更新間隔是什麼。 –

+0

如果你想讓它適用於iOS 7的背景,你可以在這裏試試這個解決方案:http://stackoverflow.com/questions/18946881/background-location-services-not-working-in-ios-7/ 21966662#21966662如果您有任何問題,歡迎您加入我們的討論:http://mobileoop.com/background-location-update-programming-for-ios-7 – Ricky

回答

1

你可以在你AppDelegate.m

- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
    bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ 
     NSLog(@"ending background task"); 
     [[UIApplication sharedApplication] endBackgroundTask:bgTask]; 
     bgTask = UIBackgroundTaskInvalid; 
    }]; 

    timer = [NSTimer scheduledTimerWithTimeInterval:5 
     target:locationManager 
     selector:@selector(startUpdatingLocation) 
     userInfo:nil 
     repeats:YES 
    ]; 
} 
相關問題