简体   繁体   中英

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

I am working in a iOS/xamarin app. (iOS 8). I was using this tutorial to know the user location: http://www.themethodology.net/2014/10/getting-permission-to-access-user.html

And the follow codes works to know if the uses has the location services enabled and if the applications is authorized to use the location.

CLLocationManager clm = new CLLocationManager ();

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

But, if the user select the first time: Don't allow, after that, he changes the permission in:

Privacy >> Location >> MyApp >> ON

The IsAuthorized method is always false. Someone has an idea about how solve this issue?

I found the way to know if the application has permission to use the location services (Not if the service is enabled).

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

You can use CLAuthorizationStatus.AuthorizedWhenInUse when the app is using AuthorizeWhenIsInUser and if you are using AuthorizedAlways you need change that in the CLAutorizationStatus . Also, is necessary for iOS 8 modify the keys in your plist file: More information about the plist here. http://www.themethodology.net/2014/10/getting-permission-to-access-user.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM