requestAlwaysAuthorization が権限アラートを表示しない 質問する

requestAlwaysAuthorization が権限アラートを表示しない 質問する

私はいくつかの派手な iBeacons を使用しようとしていますが、うまくいかず、常に kCLAuthorizationStatusNotDetermined になります。他の質問によると、これらのキーを info.plist に追加することが必須です (質問によっては 1 つ、他の質問では両方)。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];

最後の 2 つの方法のいずれかを実行するまで、設定/プライバシー/位置情報にアイコンは表示されませんでした。許可を承認するためのアラート ビューは表示されません。位置情報設定で手動で変更して確認すると、ステータスが変更されますが、しばらくすると、設定の位置情報によってアプリの「常に」ステータスが削除され、再び空白になります。後で確認しましたが、運がありませんでした。

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

何が足りないのか、何が間違っているのか、何かアイデアはありますか? ありがとうございます

ベストアンサー1

iOS 11 開発者の方は、この投稿をご覧ください。iOS 11 で位置情報サービスが機能しない


TL;DR: Info.plist には 3 つの場所キーがすべて必要です。

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

InfoPlist.strings多言語アプリの場合は翻訳も行います。

おすすめ記事