My app runs two quick background download tasks evey time a background fetch is sent to it by the OS. A local notification "GotData" is sent by the background task when the web data has arrived and was processed.
In normal active operation I register my app's root view controller, "Main", to receive the local notification "GotData". This works fine and allows the view to get updated as soon as the fresh data has arrived.
override func viewDidLoad() {
super.viewDidLoad()
let notificationName = Notification.Name("GotData")
NotificationCenter.default.addObserver(self, selector: #selector(updateGUI), name: notificationName, object: nil)The view removes itself from receiving notifications:
override func viewWillDisappear(_ animated: Bool) {
NotificationCenter.default.removeObserver(self)
}When the app is in the foreground, receiving the notification causes only the selector to run, not the entire VDL. When the app has been in the background a while and the web fetch completes and sends the GotData notification, it seems that the entire Main VDL is rerun. It responds to the notifcation (which is fine) but then also does all the ususal VDL stuff. This is a problem because it's unanticipated. It does not happen all the time even when the app is in the background, but seems likely to be happening when it comes out of suspension.
Does it make sense the entire VDL is run in full when the notification is sent by the background download task?