我有一個具有明確用戶交互的應用程序,該用戶可以使用用戶的當前位置。如果用戶拒絕訪問位置服務,我仍然希望隨後的使用能夠提示用戶轉到設置併爲我的應用重新啓用位置服務。如何在用戶拒絕使用後提示用戶打開位置服務
我想要的行爲是內置的地圖應用:
- 在設置復位位置警告>通用>還原>還原位置警告。
- 啓動地圖應用程序。
- 點擊左下角的當前位置按鈕。
- 帶「」地圖「的地圖提示將使用您當前的位置」| 「不允許」| 「允許」。
- 選擇「不允許」選項。
- 再次點擊左下角的當前位置按鈕。
- 將地圖提示與「打開位置服務以允許」地圖「確定您的位置」| 「設置」| 「取消」。
在自己的應用程序,同樣的基本流程的結果在我的CLLocationManagerDelegate -locationManager:didFailWithError:方法被調用了kCLErrorDenied錯誤,在最後步驟,並且用戶沒有給出,打開設置應用程序來糾正選項它。
我可以顯示自己的警報來響應錯誤,但它不能啓動設置應用程序,就像操作系統可以提供內置地圖應用程序所使用的警報一樣。
CLLocationManager類中有什麼我缺少能夠給我這種行爲嗎?
現在,我只是顯示一個警告用戶,要求他們去設置以重新啓用它。我也很想聽到更好的解決方案。 – donkim 2011-02-03 23:22:13
我也想回答這個問題,當然還有更好的方法 – conorgriffin 2011-02-21 19:46:58
我發現CoreLocation並不滿足這個原因。我最終使用了容易整合和有據可查的skyhook庫。座標似乎也更精確。唯一的缺點是必須將1.5MB dylib與應用程序捆綁在一起。 – 2011-03-17 13:32:50