Is is possible to perform some specific task after some specific time when app state goes to terminate/not running state.
func applicationDidEnterBackground(application: UIApplication) {
print("APP in background state") // Working fine
NSTimer.scheduledTimerWithTimeInterval(5.0, target: self, selector: "backService", userInfo: nil, repeats: true)
}
But when app state goes to terminate state then its not working?
func applicationWillTerminate(application: UIApplication) {
NSTimer.scheduledTimerWithTimeInterval(5.0, target: self, selector: "backService", userInfo: nil, repeats: true)
}
I also tried
func applicationWillTerminate(application: UIApplication) {
let application = UIApplication.sharedApplication()
self.applicationDidEnterBackground(application)
application.beginBackgroundTaskWithExpirationHandler {
NSTimer.scheduledTimerWithTimeInterval(5.0, target: self, selector: "backService", userInfo: nil, repeats: true)
}
}