NEW: My new book Pro SwiftUI is out now – level up your SwiftUI skills today! >>

SOLVED: General questions about iOS apps

Forums > 100 Days of SwiftUI

  1. When you put an app in the background is it "killed" or its still active? If its active then how long does it stays active in the background?

  2. Can the user return to the screen they left from when leaving the app (Not the homescreen)

Thank you!

   

  1. If the app is in the background it's not killed. But it can't do any work. It sleeps, so to speak.
  2. Yes. They can. In general, this is the default behaviour.

   

@Hatsushira - Thank you for the reply first of all! Second, I thought on iPhones you cant "kill" an app. It just goes to sleep and the system itself decides when to put it down depending on the battery and phone performances...or something like that.

In case you are right then if the application is put to "sleep" then for how long the app will be sleeping until the systems shuts it down? Because from my understanding no app can sleep indefinetly.

   

You can "kill" apps on the iPhone. Perhaps the behaviour you describe was in the past. I don't know. But I usually end my apps and none is sleeping in the background on my phone.

Every now and then I visit my mother and there are a lot of apps sleeping in the background. So I don't think they are forced to shut down when they sleep in the background.

There is a functionality on OS level when your app is using too much energy or CPU power the app is shut down by the OS. But if your app just sleeps in the background it isn't.

But to be clear, you can't do much work in your app when your app is in the background. If this is what you want to do. There are only specific background modes which are allowed. And the app will be killed if it uses too much power/CPU on OS level.

   

When an app goes into background it stop doing work (sleep) unless doing specific background work, however does stay in the RAM, iOS will completely close (kill) the app when it need the RAM for other apps. So there is no time limit that the app will "sleep" before it "killed" as it depends on how many apps the user uses or/and how much RAM an app needs. However a user can force close an app at anytime! If you want your app to return to the same screen then do a setting (user defaults etc) to save this when the app moves to the background.

   

You can force quit apps in iOS, but you shouldn't. Unless an app is misbehaving, forcing it to quit offers no benefits and can even be detrimental.

Do not close iPhone and iPad 'background'… - Apple Community

   

Thank you everyone. Very helpfull info!

   

Hacking with Swift is sponsored by Judo

SPONSORED Let’s face it, SwiftUI previews are limited, slow, and painful. Judo takes a different approach to building visually—think Interface Builder for SwiftUI. Build your interface in a completely visual canvas, then drag and drop into your Xcode project and wire up button clicks to custom code. Download the Mac App and start your free trial today!

Try now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.