CLLocationManager and tvOS – RequestWhenInUseAuthorization() not prompting

I seem to be having a little trouble getting tvOS to prompt the user for location data authorization. I literally copied and pasted working code from iOS and it seems to not be prompting the user. I am using the code listed below as well as the NSLocationWhenInUseUsageDescription key with a string value. The only difference in the api that I see is on iOS it uses startupdatinglocation() and on tvOS it uses requestLocation() (similar to watchOS) I’ve stepped through the problem and it is infact hitting requestWhenInUseAuthorization() but simply doesn’t prompt the user.

Any idea what is going on?

  • UICollectionView sticky header in swift
  • How to make a UIView focusable using the focus engine on Apple TV
  • UIButton on different Y level can't be focused on tvOS
  • TVOS remote notification replacement
  • Change background color for page control
  • How do I open another application with tvOS?
  • 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()
        }
    
      }
    
    }
    

    Solutions Collect From Internet About “CLLocationManager and tvOS – RequestWhenInUseAuthorization() not prompting”

    It turns out that a CFBundleDisplayName key and $(PRODUCT_NAME)value is needed in order for the prompt to display.