Reputation:
How do I detect that an app has launched into the background state? Needless to say regular apps cannot do this, only a small set of apps of the proper type can, and it is not an ideal situation. In particular Newsstand apps do this.
Upvotes: 12
Views: 2749
Reputation: 21967
Hard to believe nobody answered this correctly yet. From the iOS App Progamming Guide:
To determine whether your app is launching into the foreground or background, check the applicationState property of the shared UIApplication object in your application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions: delegate method. When the app is launched into the foreground, this property contains the value UIApplicationStateInactive. When the app is launched into the background, the property contains the value UIApplicationStateBackground instead. You can use this difference to adjust the launch-time behavior of your delegate methods accordingly.
Upvotes: 24