UIApplicationStateInactive used instead of UIApplicationStateBackground.