iPhone Multitasking - SOLVED

Hi there,

I’m sorry if this is a dumb question but here goes…

I have written an app for a client and it works great on the pre-iOS4/multitasking phones. The correct functionality is that while the user is running the app, if he presses the home key, the application quits and therefore next time they click on the app icon, it will load and run the app from the start.

Now, with iPhone 4 and the latest iOS, it seems that pressing the home button by default just pushes the app onto the multitasking stack and keeps it running. If my client was then to press the app icon (in the app list, not from the multitasking taskbar at the bottom), it just resumes the app rather than running it from the start.

My question is, how do I get around this? I want users of the app to be able to press their home button and it effectively close the app OR when they click on the app icon (while the app is still multitasking), it detects this so that I can force the running app to start from the beginning again.

Hopefully I’m just missing something simple here.

Thanks for the help.

Cheers,

-Rob.

yes you miss something: iOS does not offer any kind of real multitasking (there are 5 types of tasklets, but of those 5 only two work with unity at all and local notification requires that you work with xcode, unity doesn’t offer access to it)

when you press home, it is pushed into background and goes to sleep, it won’t continue processing anything (can be good but also bad if you have bad code that relies on Time.time which is always a fault, always use accumulators that use Time.deltaTime, thats always correct including timescale scenarios etc), this is also known as fast app switch.

unity since iOS2 in this case automatically set itself and audio on pause when it was no longer active (prior to iOS4 this happend on notifications, phone calls, sms notification etc)

if you really want it to quit, you need to specify a specific key in the plist file that tells iOS to kill it. Check the iOS documentation from apple and the official dev boards at apple on this matter if you are interested in this option

Alternatively, users can just kill them manually as the task lists works through the same “delete” method as normal apps: press finger on it for 2 seconds and you can terminate sleeping processes

Thanks Dreamora,

You’re always there to help!

With a bit of searching, I found the answer. For anyone interested, the answer is to add

UIApplicationExitsOnSuspend as a key in your info.plist and set it to YES

I haven’t tested it yet. Must wait for my friend’s iPhone 4 to get here but I will mark this thread as fixed once I have tested it.

Cheers,

-Rob.

It won’t work in dev builds from my experience, so you might want to start the testing with adhoc :slight_smile:

Got it working.

It must be of boolean type or it won’t work.

I’ll mark this thread as solved.

Cheers,

-Rob.

Just to add something… you don’t always have to use this key.

Obstacle Alley seems to have no issue being paused and resumed, and I’m sure it holds for many other apps. As dreamora suggested check your usage of the time functions.

I wonder if there are other functions that might cause issues?

My application worked fine being paused and resumed too.

That wasn’t the problem.

My client wanted the functionality whereby when you clicked on the app icon, that it would restart the app from the beginning, even if it was put to sleep by pressing the home button.

Thus, the use of the key to force it to restart.

-Rob.

Forgive my lazy skimming :s