2014-06-20 47 views
0

我需要知道什麼時候gps不工作。對於所有應用程序的切換器正確,locationServicesEnabled = YES或NO,但如果我打開應用程序的位置並關閉我的應用程序,locationServicesEnabled YES,但gps不可用。 而且在這種情況下也不會顯示消息「啓用位置服務以允許」MyApp「確定您的位置」。CLLocationManager locationServicesEnabled打開但個人關閉

我如何確定我的應用的位置是關閉的?

+0

這已經回答了問題: http://stackoverflow.com/questions/9825118/how-to-detect-if-user-did-not-allow- location-update/9825147#9825147 –

回答

1

我希望你正在尋找

[CLLocationManager authorizationStatus] 

它返回的這些

kCLAuthorizationStatusNotDetermined = 0, 
kCLAuthorizationStatusRestricted, 
kCLAuthorizationStatusDenied, 
kCLAuthorizationStatusAuthorized, 
kCLAuthorizationStatusAuthorizedAlways = kCLAuthorizationStatusAuthorized, 
kCLAuthorizationStatusAuthorizedWhenInUse 

這是每狀態報告應用一個,不是每個設備

更新
固定位置經理類名按照Denis的評論

+0

謝謝。它幫助我找到解決方案。最喜歡什麼CoreLocationManager已棄用。我使用CLLLocationManager,並在這裏找到示例:http://stackoverflow.com/questions/15377069/kclauthorizationstatusnotdetermined-occurred-when-tested-with-ios-6-1-simulator –

+1

@DenisS - 對不起,我是從記憶中。 CLLocationManager是正確的,我已經修復了答案。我在測試應用程序的信標[這裏](http://www.github.com/foundry/ibeacons)中使用它 - 請參閱[MBCLHelpers類](https:// github)中的「+(void)logAvailability'。 COM /鑄造/ ibeacons /斑點/主/ MyBeacon/MBCLHelpers.m) – foundry