I have an iOS app which uses CoreLocation and WiFi SSID information. My app was working fine until iOS 13 arrived but since then it's giving me a lot of issues especially when app goes in background. I have been using one timer in background as background task which also not work after 30 seconds and especially app got killed in background in the same time frame. I have seen some people saying that iOS 13 has been strict for background task and timing but I still have not found any direct references or links by apple which supports this claims. Is there anyone else facing the same issues then please share your insights. Thanks
I have one background task for timer:
var bgTask: UIBackgroundTaskIdentifier?
var updateTimer: Timer?
func applicationDidEnterBackground(_ application: UIApplication) {
bgTask = application.beginBackgroundTask(withName: "MyTask", expirationHandler: {() -> Void in
if let bgTask = self.bgTask {
application.endBackgroundTask(bgTask)
self.bgTask = UIBackgroundTaskIdentifier(rawValue: convertFromUIBackgroundTaskIdentifier(UIBackgroundTaskIdentifier.invalid))
}
})
DispatchQueue.main.async(execute: {() -> Void in
self.updateTimer = Timer.scheduledTimer(timeInterval: 2.0, target: self, selector: #selector(self.checkNetworkStatus), userInfo: nil, repeats: true)
})
}
@objc func checkNetworkStatus() {
print("Timer calledddd")
}