How to get detect Home button press?

OnApplicationPause seems to not be working for me. Is it supposed to work or is there another route in which you can detect the press of the home button?

Also, if someone presses home, and the application goes into the background, does unity pause code execution? Or does it still update in the background?

Unity Pauses when the app goes into the background, except on devices running pre iOS4 where it just exits.
I’m pretty sure noting in unity’s code can update while it’s in the background.

OnApplicationPause works, but it only runs when you return to the app from multitasking.

Put something like this in your code and run it through Xcode, then check how this appears when you exit and return to the app.

function OnApplicationPause(){
    print ("paused!");
}

It actually runs when paused and resumed. It gets passed a boolean as an argument to determine which one exactly.

I see, not sure what I was doing wrong.

Thank you.

Sorry for resurrecting old thread. But OnApplicationPause() is not getting triggered on Home button press. The app continues to run in the background. I also tried OnApplicationFocus() but that works if application goes out of focus for keyboard and mouse inputs. Whats the best way to detect home button press?