如何第二次请求用户许可以允许访问当前位置? [英] How to ask permission from user for second time to allow to access the current location?

查看:131
本文介绍了如何第二次请求用户许可以允许访问当前位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,如果用户不允许访问其当前位置,我可以通过以下方式接收该消息

In my app, if the user not allowed to access their current location, I can recieve that message in the following method

- (void)locationManager:(CLLocationManager*)aManager didFailWithError:(NSError*)anError
{
    switch([anError code])
    {
       case kCLErrorLocationUnknown: 
        break;

        case kCLErrorDenied:
        {
           UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Access Denied" message:@"You didn't allow to access your current location" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
            [alert show];
          break;
        }
    }
 }

如何询问用户权限第二次?

How to ask the user permission for the second time?

我搜索并得到了答案否,如果用户希望该应用访问他/她的位置,他/她如何设置应用程序使用他们当前的位置?

I searched and got the answer NO, If the user wants the app to access his/her location, how he/she set the app to use their current location?

是删除应用并下载另一个唯一的解决方案吗?

Is deleting the app and download another one the only solution?

推荐答案

我认为您可以从设备设置 - >位置服务选项卡打开位置服务..请参阅下面的图像

I think you can turn on Location Services from device Settings -> Location Services tab.. See the image below

更新:
当应用程序的位置服务关闭时,位置管理器将触发错误,错误代码为 kCLErrorDenied ,然后您可以向用户显示警报以启用设置中的位置服务..

Update: When location services is off for an app, the location manager will fire error with error code kCLErrorDenied then you can show an alert to user to Turn On location services from settings..

或者,您也可以使用以下代码

Or, you can use the following code too

if (![CLLocationManager locationServicesEnabled])

这篇关于如何第二次请求用户许可以允许访问当前位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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