gpt4 book ai didi

ios - requestAlwaysAuthorization 不显示权限警报

转载 作者:IT王子 更新时间:2023-10-29 07:52:10 29 4
gpt4 key购买 nike

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

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

在 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];

在执行最后两种方法之一之前,图标不会出现在“设置”/“隐私”/“位置”中。批准权限的警报 View 永远不会出现。如果我在位置设置中执行手动更改并检查它会更改状态,但几分钟后,设置中的位置将删除我的应用程序的“始终”状态,并再次将其留空。后来我检查没有运气

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

有什么遗漏或错误的想法吗?谢谢

最佳答案

对于 iOS 11 开发者,您应该看看这篇文章:Location Services not working in iOS 11 .


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

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

在多语言应用的情况下连同 InfoPlist.strings 翻译。

关于ios - requestAlwaysAuthorization 不显示权限警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26005122/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com