requestAlwaysAuthorization not showing permission alert

前端 未结 17 1073
我寻月下人不归
我寻月下人不归 2020-12-29 20:19

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

17条回答
  •  孤城傲影
    2020-12-29 21:16

    Swift 3.X Latest code easily usage

    import CoreLocation
    
     public var locationManager = CLLocationManager()
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
    
            locationManager.delegate = self
            locationManager.requestAlwaysAuthorization()
            locationManager.startUpdatingLocation()
    
    }
    
    
    
        func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    
            let altitudeG = locations.last?.altitude
            let longitudeG = locations.last?.coordinate.longitude
            let latitudeG = locations.last?.coordinate.latitude
    
    print("\(altitudeG) \(longitudeG) \(latitudeG)")
    
        }
    

提交回复
热议问题