Sorry I am stuck, but I am trying to start background task (XCode8, swift 3)
In AppDelegate.swift:
func applicationDidEnterBackground(_ application: UIApplication) {
var bgTask: UIBackgroundTaskIdentifier = 0;
bgTask = application.beginBackgroundTask(withName:"MyBackgroundTask", expirationHandler: {() -> Void in
print("The task has started")
application.endBackgroundTask(bgTask)
bgTask = UIBackgroundTaskInvalid
})
}
The app has never shown "The task has started" message. What am I doing wrong?