2012-02-09 19 views
1

我想訪問用戶當前Location.When我調用CLLocationManager(startUpdating)。CLLocation Manager(如何啓用「使用當前位置」)

其顯示的是alertview ex。 「Xyz App想要使用您當前的位置」。 如果用戶點擊「不允許」。現在如果我檢查授權狀態,它回覆2「表示拒絕」。 我檢查狀態,如果它的2(手段拒絕),我會讓showalertview「某某想用你的當前位置」

現在,如果用戶點擊「允許」如何以編程方式啓用它,而不是用戶去設置屏幕&手動啓用。

回答

4

您不能以編程方式啓用用戶點擊不允許的方式。您只需通知用戶,他必須轉到設置 - >定位服務,併爲您的應用啓用它,如果他想使用此功能。

您可以設置該位置的purpose,它將顯示在操作系統顯示的第一個警報視圖中,當將要求用戶許可時。

purpose 

An application-provided string that describes the reason for using location services. 
@property(copy, nonatomic) NSString *purpose 
Discussion 

If this property is not nil and the system needs to ask for the user’s consent to use location services, it displays the provided string. You can use this string to explain why your application is using location services. 

You must set the value of this property prior to starting any location services. Because the string is ultimately displayed to the user, you should always load it from a localized strings file. 
+0

如果用戶點擊了不允許。下次如果用戶再次去app.Its不顯示alertview。 – Rupesh 2012-02-09 07:30:15

+0

沒有那只是當應用程序嘗試訪問位置服務時第一次。每次您必須檢查CLAuthorizationStatus並根據它提醒用戶 – 2012-02-09 07:40:52

+0

他們是沒有其他方法沒有以編程方式啓用服務? – Rupesh 2012-02-09 07:42:45