requestAlwaysAuthorization未显示权限警报 [英] requestAlwaysAuthorization not showing permission alert

查看:633
本文介绍了requestAlwaysAuthorization未显示权限警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用一些花哨的iBeacons但没有成功,kCLAuthorizationStatusNotDetermined一直都是。
根据其他问题,需要将这些密钥添加到info.plist(有些问题说一个,另一个问题说两者都有)。根据iBeacons的文章,我需要Always选项。

I'm trying to use some fancy iBeacons without success, kCLAuthorizationStatusNotDetermined all time. According to other questions it's a requirement to add those keys to info.plist (some questions says one, other says both). According to an article for iBeacons I need the Always option.

<key>NSLocationWhenInUseUsageDescription</key>
<string>Nothing to say</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Permiso para acceder siempre</string>

在viewDidAppear:

At viewDidAppear:

self.locManager = [[CLLocationManager alloc]init];
self.locManager.delegate = self;
[self.locManager requestAlwaysAuthorization];
NSUUID* region1UUID = [[NSUUID alloc]initWithUUIDString:@""]; //ibeacon real UUID between "". Checked it's not nil.

self.beaconRegion = [[CLBeaconRegion alloc]
                                initWithProximityUUID:proximityUUID
                                identifier:@"myCoolString"];

self.beaconRegion.notifyEntryStateOnDisplay = YES;
self.beaconRegion.notifyOnEntry = YES;
self.beaconRegion.notifyOnExit = NO;
[self.locManager startMonitoringForRegion:self.beaconRegion];
[self.locManager startRangingBeaconsInRegion:self.beaconRegion];

图标未出现在设置/隐私/位置,直到执行了最后两种方法之一。永远不会出现批准权限的警报视图。
如果我在位置设置中执行手动更改并进行检查,则会更改状态,但过了一会儿,设置中的位置将删除我的应用的始终状态,并将其再次留空。后来我没有运气检查

Icon didn't appear at Settings/Privacy/Location until it was executed one of the two last methods. The Alert View to approve permissions never appears. If I perform a manual change at Location Settings and check it it will change status but at a few moments later Location at Settings will delete "Always" status for my app and will leave it blank again. Later I check with no luck

-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {

任何想法缺失或错误?谢谢

Any ideas what is missing or wrong? Thank you

推荐答案

对于iOS 11开发人员,你应该看一下这篇文章:位置服务在iOS 11中无效

For iOS 11 developers, you should take a look at this post: Location Services not working in iOS 11.

TL; DR:您需要Info.plist中的所有三个位置键:

TL;DR: you need ALL THREE location keys in the Info.plist:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>...</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>...</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>...</string>

以及 InfoPlist.strings 翻译以防万一多语种应用程序。

Along with InfoPlist.strings translations in case of multilingual apps.

这篇关于requestAlwaysAuthorization未显示权限警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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