Although I think this is a fairly trivial question, I could not find any answers out there.
My question is:
Is there a way to get a notification in a MonoTouch iPhone application when my application is being closed or sent to background (by a user clicking the home button)?
I thought the WillTerminate
override was good for this, but in the debugger, it is never called.
There are two ways to get notified when an app goes to the background:
a. Override the appropriate method in your AppDelegate:
b. Add notification observers through the NSNotificationCenter class:
You can use the NSObject object returned from the AddObserver method to remove the observer when you no longer need it: