【问题标题】:Deny the location permission and later grant the location for xamarin iOS 8 application return always false拒绝位置权限并稍后授予 xamarin iOS 8 应用程序的位置返回始终为 false
【发布时间】:2014-11-08 20:31:48
【问题描述】:

我正在使用 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 方法总是错误的。 有人知道如何解决这个问题吗?

【问题讨论】:

    标签: ios gps xamarin location


    【解决方案1】:

    我找到了知道应用程序是否有权使用位置服务的方法(如果服务已启用,则不会)。

    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

    【讨论】:

      猜你喜欢
      • 2019-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-21
      • 2014-10-01
      • 1970-01-01
      • 2017-02-27
      相关资源
      最近更新 更多