[UIApplication applicationState]
The runtime state of the application. (read-only)
@property(nonatomic, readonly) UIApplicationState applicationState
Discussion of [UIApplication applicationState]
An application may be active, inactive, or running in the background. You can use the value in this property to determine which of these states the application is currently in.
Example of [UIApplication applicationState]
UIApplicationState applicationState = [UIApplication sharedApplication].applicationState;
Example of [UIApplication applicationState]
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// get state
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
//the app is in the foreground, so here you do your stuff since the OS does not do it for you
//navigate the "aps" dictionary looking for "loc-args" and "loc-key", for example, or your personal payload)
}
application.applicationIconBadgeNumber = 0;
}
Example of [UIApplication applicationState]
if ([[UIApplication sharedApplication] respondsToSelector:@selector(applicationState)] ){
UIApplicationState state = [[UIApplication sharedApplication] applicationState];
}