with this code my app works good,but when i get back in foreground all function are disable....who can I get work in foreground?
func applicationDidEnterBackground(_ application: UIApplication) {
var finished = false
var bgTask: UIBackgroundTaskIdentifier = 0;
bgTask = application.beginBackgroundTask(withName:"MyBackgroundTask", expirationHandler: {() -> Void in
// Time is up.
if bgTask != UIBackgroundTaskInvalid {
// Do something to stop our background task or the app will be killed
finished = true
}
})
// Perform your background task here
print("The task has started")
while !finished {
print("Not finished")
// when done, set finished to true
// If that doesn't happen in time, the expiration handler will do it for us
}
// Indicate that it is complete
application.endBackgroundTask(bgTask)
bgTask = UIBackgroundTaskInvalid
}