2010-02-25 71 views
17

現在我還沒有想到這一點。如何處理位置管理器的「不允許」?

直到現在,每當設備問我使用位置更新,我允許它。

但是,現在我不允許然後它的位置管理器給我kclErrorDenied和位置管理器無法重新啓動,直到我重新啓動應用程序。

所以我的問題是,我應該給消息重新啓動應用程序給用戶還是有一個解決方案,再次開始工作的位置管理器。

謝謝。

The Error : 
ERROR,Time,288787555.078,Function,"void CLClientHandleDaemonDataRegistration(__CLClient*, const CLDaemonCommToClientRegistration*, const __CFDictionary*)",server did not accept client registration 1 
WARNING,Time,288787555.108,Function,"void CLClientHandleDaemonInvalidation(__CFMessagePort*, void*)",client 1308.0 has been disconnected from daemon 
locationManager:didFailWithError:] [Line 244] Error Denied :Error Domain=kCLErrorDomain Code=1 "Operation could not be completed. (kCLErrorDomain error 1.)" 

回答

36

實施- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error { 
    NSMutableString *errorString = [[[NSMutableString alloc] init] autorelease]; 

    if ([error domain] == kCLErrorDomain) { 

     // We handle CoreLocation-related errors here 
    switch ([error code]) { 
     // "Don't Allow" on two successive app launches is the same as saying "never allow". The user 
     // can reset this for all apps by going to Settings > General > Reset > Reset Location Warnings. 
     case kCLErrorDenied: 
      //... 
      break; 
     case kCLErrorLocationUnknown: 
      //... 
      break; 
     default: 
      //... 
      break; 
     } 
    } else { 
     // We handle all non-CoreLocation errors here 
    } 
} 
+0

因此操作系統會問這兩次,如果我們不允許我們重新啓動應用程序的時間,是不是? – harshalb 2010-02-25 12:15:09

+1

是的,如果應用程序絕對需要當前位置。 – willi 2010-02-26 00:03:32

+5

不... @willi不正確。該應用程序會問一次。第一次。您無法再發起第二次請求。蘋果要求你讓用戶知道(當他們點擊不允許時),你的程序在沒有地理位置的情況下將無法工作。如果需要,請告訴用戶重新啓動應用程序。如果您的應用程序無法正常工作,請繼續並繼續應用程序。無論如何,您必須讓用戶知道或Apple不會批准您的應用。 ps:他們*做*檢查這個...所以做對了。 – Jann 2010-02-28 08:16:55