我有以下内容:
class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
...
let locationManager = CLLocationManager()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if CLLocationManager.locationServicesEnabled() {
locationManager.delegate = self
locationManager.allowsBackgroundLocationUpdates = true
locationManager.distanceFilter = 3000.0
locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
}
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
print("my location: \(locations.first?.coordinate)")
locationManager.stopUpdatingLocation()
locationManager.delegate = nil
}
}
但即使关闭应用程序,我也会在状态栏中看到位置服务图标:
我想知道是否有办法以编程方式禁用它。提前谢谢!
答案 0 :(得分:0)
在plist文件中,您必须确保位置行为Privacy - LocationAlwaysUsageDescription
而不是var myApp = angular.module('myAppUpdate',[])
//this is called twice in your code, with the brackets you are
//instanciating the module.