Handling app life cycle events

Hi all,
As lot’s more people seem to be using Codea to make universal apps I was wondering if there’s a method or function that is called to handle app lifecycle changes. Things like when the app is interrupted by an incoming phone call, or when the home button is pressed or when the app is closed (via the homescreen).

I’ve searched the forums and the docs and I can’t find one.

I’ve also looked in the source to the exported app and I can see that there are handlers there in AppDelegate.mm but they don’t seem to be wired up. Is this an easy thing to retrofit to the exported projects.

What I’m looking for is a way for my app to get notified so I can force a save of any local state data along with setting a flag so that I can ensure pause mode is active when my app is restarted.

Thanks in advance.