简体   繁体   中英

Why is my iOS app suspended instantly when in background

I have coded an iOS app that sends data via post to a Web service every second.

I wish to make this app run in the background indefinitely but before that I realized my app is getting suspended instantly when I hit the home button.

From my research on iOS (I'm very new to this), I read that all apps are given at least a few minutes to run in the background. My app already has location and updates in Background Modes checked (even though this is not yet implemented).

My question is, is it normal for the app to be suspended immediately when I hit the home button? And if possible how do I stop it?

You can only run an app in the background it falls in one of the available background modes and. Like you poste you already have the location and updates mode there. You will have to track the user location for your app not to be suspended, this has to do with saving the battery charge.

If you mis use the background mode in your app, Apple will reject it. So if you use the background mode location and updates and you app is not doing anything the location update it will be rejected.

You should really ask you self whether it is necessary to keep your app running. For example if you just want to finish uploading some data use Executing Finite-Length Tasks .

User experience is one of the most important features of iOS, thus you should not make you app drain battery when it is not necessary or when it can be done more effeciant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM