簡體   English   中英

拒絕位置權限,然后再授予xamarin iOS 8應用程序的位置,返回false

[英]Deny the location permission and later grant the location for xamarin iOS 8 application return always false

我正在使用iOS / xamarin應用程序。 (iOS 8)。 我正在使用本教程來了解用戶位置: http : //www.themethodology.net/2014/10/getting-permission-to-access-user.html

並且以下代碼可以了解用戶是否啟用了位置服務,以及應用程序是否有權使用該位置。

CLLocationManager clm = new CLLocationManager ();

public bool LocationServicesEnabled {
            get {return CLLocationManager.LocationServicesEnabled;}
        }
        public bool IsAuthorized {
            get {return CLAuthorizationStatus.Authorized == _authstatusLast;}
        }

但是,如果用戶是第一次選擇:不允許,那么之后,他會在以下位置更改權限:

Privacy >> Location >> MyApp >> ON

IsAuthorized方法始終為false。 有人對如何解決這個問題有想法嗎?

我找到了一種方法來知道應用程序是否具有使用位置服務的權限(如果啟用了該服務,則不是)。

public bool IsAuthorized {
            get {return CLLocationManager.Status == CLAuthorizationStatus.AuthorizedWhenInUse ;}
        }

當應用程序使用AuthorizeWhenIsInUser時,您可以使用CLAuthorizationStatus.AuthorizedWhenInUse ;如果您使用的是AuthorizedAlways ,則CLAutorizationStatus需要在CLAutorizationStatus中進行CLAutorizationStatus 另外,對於iOS 8來說,必須修改plist文件中的鍵:有關此處的plist的更多信息。 http://www.themethodology.net/2014/10/getting-permission-to-access-user.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM