To check the status, you can do something like:
[[UIApplication sharedApplication] applicationState]==UIApplicationStateInactive
or
[[UIApplication sharedApplication] applicationState]==UIApplicationStateActive
If you want to receive notifications, you can:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourselector:) name:UIApplicationDidBecomeActiveNotification object:nil];
or
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(yourselector:) name:UIApplicationDidEnterBackgroundNotification object:nil];
You can also make other notifications (from https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/ ):
UIApplicationDidBecomeActiveNotification UIApplicationDidChangeStatusBarFrameNotification UIApplicationDidChangeStatusBarOrientationNotification UIApplicationDidEnterBackgroundNotification UIApplicationDidFinishLaunchingNotification UIApplicationDidReceiveMemoryWarningNotification UIApplicationProtectedDataDidBecomeAvailable UIApplicationProtectedDataWillBecomeUnavailable UIApplicationSignificantTimeChangeNotification UIApplicationUserDidTakeScreenshotNotification UIApplicationWillChangeStatusBarOrientationNotification UIApplicationWillChangeStatusBarFrameNotification UIApplicationWillEnterForegroundNotification UIApplicationWillResignActiveNotification UIApplicationWillTerminateNotification UIContentSizeCategoryDidChangeNotification
If you want to use the application delegate, you can use:
- (void)applicationDidEnterBackground:(UIApplication *)application {}
or
- (void)applicationDidBecomeActive:(UIApplication *)application {}
source share