applicationDidResignActive(_:) and inactive state

Hi all! I have, maybe, a stupid question. I need from my app, when some files or folder are dropped in, to perform some kind of activities(like upload, implemented with background session, to a server). I noticed that when applicationDidResignActive is called the system continue the actual upload operation and stop immediately after this operation terminate. What’s the right way to implement actions that can run also when this state change happens? What I’m missing?

Thank you in advance.

applicationDidResignActive(_:) and inactive state
 
 
Q