[英]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 / xamarin应用程序。 (iOS 8).
(iOS 8)。 I was using this tutorial to know the user location: http://www.themethodology.net/2014/10/getting-permission-to-access-user.html
我正在使用本教程来了解用户位置: 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. IsAuthorized
方法始终为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
. 当应用程序使用
AuthorizeWhenIsInUser
时,您可以使用CLAuthorizationStatus.AuthorizedWhenInUse
;如果您使用的是AuthorizedAlways
,则CLAutorizationStatus
需要在CLAutorizationStatus
中进行CLAutorizationStatus
。 Also, is necessary for iOS 8 modify the keys in your plist
file: More information about the plist here. 另外,对于iOS 8来说,必须修改
plist
文件中的键:有关此处的plist的更多信息。 http://www.themethodology.net/2014/10/getting-permission-to-access-user.html http://www.themethodology.net/2014/10/getting-permission-to-access-user.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.