Prevent my application from being suspended in bac

2019-06-09 08:38发布

问题:

This question already has an answer here:

  • Is there a way to prevent iOS6 to kill the specific task process? 2 answers

My application is suspended by iOS after some time -- from one hour to several days -- but I want it to work in the background as long as possible (maybe infinitely) while the device is running. SMS will notify the user all the time that the device is running -- iOS doesn't kill the SMS service. My app has similar functionality and should notify user about the new income messages and so on.

So can I do the same with my application? Maybe there is some hack?

回答1:

No.

There are the following exceptions:

  • Playing music
  • GPS tracking
  • VoIP

Also, all apps can get up to ten minutes to finish existing tasks.

There should be an answer if you're prepared to jailbreak, but otherwise, it's not possible with current versions of iOS.

The way around this is to do the processing on a server and send push notifications when something interesting happens.



回答2:

You don't want your application running indefinitely.

You should use push notifications. This will notify your user the same way the SMS application does.