UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

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!

2      

  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.

2      

@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.

2      

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.

2      

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.

2      

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

2      

Thank you everyone. Very helpfull info!

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot 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.