CLLocationManager和tvOS - RequestWhenInUseAuthorization()没有提示

Spr*_*982 2 cllocationmanager swift tvos

我似乎在让tvOS提示用户进行位置数据授权方面遇到了一些麻烦.我从iOS中复制并粘贴了工作代码,似乎没有提示用户.我使用下面列出的代码以及带字符串值的NSLocationWhenInUseUsageDescription键.我看到api的唯一区别是在iOS上它使用了startupdatinglocation()而在tvOS上它使用了requestLocation()(类似于watchOS)我已经逐步解决了问题,它实际上是在命令中请求USUseAuthorization()但是根本没有提示用户.

知道发生了什么事吗?

import UIKit
import CoreLocation
class ViewController: UIViewController {
  var locationManager = CLLocationManager()

  override func viewDidLoad() {
  super.viewDidLoad()

  locationManager.delegate = self
  locationManager.desiredAccuracy = kCLLocationAccuracyBest

  if CLLocationManager.locationServicesEnabled(){

    if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.NotDetermined{
      locationManager.requestWhenInUseAuthorization()
    }
    else if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse{
      locationManager.requestLocation()
    }

  }

}
Run Code Online (Sandbox Code Playgroud)

Spr*_*982 6

事实证明,需要CFBundleDisplayName键和$(PRODUCT_NAME)值才能显示提示.