繁体   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