拒绝位置权限并稍后授予xamarin iOS 8应用程序的位置返回始终为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中更改。此外,对于iOS 8,有必要修改plist文件中的密钥:有关plist的更多信息,请点击此处。http://www.themethodology.net/2014/10/getting-permission-to-access-user.html

最新更新