I have a background process in my app. Here's the code:
@available(iOS 10.0, *)
func startTimer() {
timer2?.invalidate()
timer2 = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true, block: { (t) in
if UIApplication.shared.applicationState == .background {
NSLog("tic background \(UIApplication.shared.backgroundTimeRemaining)")
if UIApplication.shared.backgroundTimeRemaining < 10 {
}
}
})
timer2?.fire()
}
However, it works only in iOS10. Is there a way to rewrite in for previous versions of iOS?