Checking iOS App State Is Background or InActive | Xcode Snippet | iOS Programmer Guide

App delegate gets callbacks indicating iOS app state transitions. We can identify if the iOS app is running in background or inactive using this.


Also "applicationState" in UIApplication gives the current state of the iOS app.
[[UIApplication sharedApplication] applicationState]
The below objective-c code snippet gives an example of checking the iOS app state

UIApplicationState state = [[UIApplication sharedApplication] applicationState];
if (state == UIApplicationStateBackground || state == UIApplicationStateInactive)
{
   //Do checking here.
}