Xamarin递归定位请求 [英] Xamarin Recursive Location Request

查看:145
本文介绍了Xamarin递归定位请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ios递归功能发送消息我的应用程序需要请求你的位置,每当用户关闭他的GPS时,消息应该再次出现,请求他的位置。



我只是使用:

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

使用这些函数,第一个返回的是服务是启用的,第二个是用户自动创建的。



刚才我可以做类似的事情:

  if(_locationServiceEnalbed&& IsAuthorized){ 
Manager = new LocationManager();
Manager.StartLocationUpdates();
}

但是没有再请求我的位置。
根据,我可以再次显示请求用户位置的消息
//developer.apple.com/library/ios/documentation/UserExperience/Conceptual/LocationAwarenessPG/CoreLocation/CoreLocation.htmlrel =nofollow> Apple ,如果他们拒绝访问您的应用,您可以申请再次尝试启动位置服务


如果返回NO,并且您尝试启动位置服务,则
系统提示用户确认是否应该重新启用位置服务
。因为用户可能故意禁用了位置
服务,提示很可能是不受欢迎的。


然而,更友好的的方法可能是显示一条消息,指出您的应用的此功能在被授予使用GPS权限之前会被禁用,并将其引导至设置菜单,以便重新启用它。


I'm working in a ios recursive function to send the message 'My App need request your location' each time that the user turn off his GPS then, the message should appears again requesting his location.

I'm just using:

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

With those functions, the first one return me is the Service is Enable and the second one if the user autorizate it.

Just now, I can do something similar to:

if(_locationServiceEnalbed && IsAuthorized){
            Manager = new LocationManager();
            Manager.StartLocationUpdates();
    }

But is not requesting me my location again. How I can display the message again requesting the user location?

解决方案

According to Apple, if they deny access to your app, you can request it again by trying to start the location services

If it returns NO and you attempt to start location services anyway, the system prompts the user to confirm whether location services should be re-enabled. Because the user probably disabled location services on purpose, the prompt is likely to be unwelcome.

However, a more friendly approach might be to display a message that this feature of your app is disabled until they grant permissions to use GPS, and to direct them to the Settings menu where it can be re-enabled

这篇关于Xamarin递归定位请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆