问题描述
该应用程序也始终具有位置权限。
我正在使用这个 startMonitoringSignificantLocationChanges 来获取位置
locationManager?.startMonitoringSignificantLocationChanges()
locationManager?.allowsBackgroundLocationUpdates = true
但手机重启后,即使应用程序没有运行,位置更新也有效。 只有当应用程序被用户在任务中杀死时,它才不起作用。
func applicationDidEnterBackground(_ application: UIApplication) {
Log.debug("Did Enter Background")
self.locationManager?.stopMonitoringSignificantLocationChanges()
self.locationManager = CLLocationManager()
self.locationManager?.delegate = self
self.locationManager?.requestAlwaysAuthorization()
self.locationManager?.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager?.distanceFilter = 500
self.locationManager?.activityType = CLActivityType.otherNavigation
self.locationManager!.allowsBackgroundLocationUpdates = true
self.locationManager?.pausesLocationUpdatesAutomatically = false
self.locationManager?.startMonitoringSignificantLocationChanges()
}
解决方法
我刚刚通过使用 allowDeferredLocationUpdates
解决了这个问题days = ['mon','tue','wed','thu','fri','sat','sun']
grouped = sleep.groupby('day_of_week')
groups = {days[i]: grouped.get_group(i).loc[:,'df'] for i in range(len(days))}