diff --git a/LocationKit/LocationDetection.swift b/LocationKit/LocationDetection.swift index 57eb584..21d579e 100644 --- a/LocationKit/LocationDetection.swift +++ b/LocationKit/LocationDetection.swift @@ -137,8 +137,8 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { } else { let components = cal.dateComponents(unit, from: item.insideDatetime, to: nowDate!) item.insideDatetime = nowDate - guard let sec: Int = components.second! - 1 else { return -1 } - return sec + guard let sec = components.second else { return -1 } + return sec - 1 } case .outside: if item.insideDatetime == nil { @@ -147,8 +147,8 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { } else { let components = cal.dateComponents(unit, from: item.insideDatetime, to: nowDate!) item.outsideDatetime = nowDate - guard let sec: Int = components.second! - 1 else { return -1 } - return sec + guard let sec = components.second else { return -1 } + return sec - 1 } } } @@ -175,7 +175,7 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { } } - private func checkStates() -> UIApplicationState { + private func checkStates() -> UIApplication.State { return UIApplication.shared.applicationState } @@ -335,13 +335,13 @@ internal class LocationDetection: NSObject, CLLocationManagerDelegate { switch status { case .authorizedAlways: detectionItem.access = .requestAlwaysAuthorization - if selfManager.backgroundTask == UIBackgroundTaskInvalid { + if selfManager.backgroundTask == UIBackgroundTaskIdentifier.invalid { selfManager.startBackgroundTask() } break case .authorizedWhenInUse: detectionItem.access = .requestWhenInUseAuthorization - if selfManager.backgroundTask != UIBackgroundTaskInvalid { + if selfManager.backgroundTask != UIBackgroundTaskIdentifier.invalid { selfManager.endBackgroundTask() } break diff --git a/LocationKit/LocationManager.swift b/LocationKit/LocationManager.swift index 192d25f..2c25d59 100644 --- a/LocationKit/LocationManager.swift +++ b/LocationKit/LocationManager.swift @@ -12,7 +12,7 @@ import CoreLocation public class LocationManager: NSObject { var regionDetectionList: [DetectionInfo] = [] open var requestAccess: RequestAccess = .requestAlwaysAuthorization - var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskInvalid + var backgroundTask: UIBackgroundTaskIdentifier = UIBackgroundTaskIdentifier.invalid public override init () { //print("LocationKit has been initialised") @@ -187,6 +187,6 @@ public class LocationManager: NSObject { internal func endBackgroundTask() { UIApplication.shared.endBackgroundTask(backgroundTask) - backgroundTask = UIBackgroundTaskInvalid + backgroundTask = UIBackgroundTaskIdentifier.invalid } }