How to determine if application is launched to do Background Fetch

ios, ios7, iphone, objective-c, xcode5

Solution

Sorry this isn't exactly a direct answer to your question, but can you achieve the same result by dividing your application launch logic between the following methods within your app delegate?

1) Any app startup logic that is common to both scenarios goes inside here:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

2) Normal launch behavior goes here:

- (void)applicationDidBecomeActive:(UIApplication *)application

3) Background fetch launch behavior goes here (slimmed down version of what is in #2):

-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

Problem

When OS launch the application for background fetch the sequence I observed is this ``` - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions ``` and then ``` -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler ``` In `didFinishLaunching` I am trying to determine if app is launched to do Background Fetch because I need to disable some features to speedup the app loading. `UIApplication` doesn't expose any property to determine this. I've noticed `UIApplication` has `_applicationFlags` which has `isHandlingBackgroundContentFetch` boolean which is set to true for Background Fetch but its inside @package and can't be accessed.

Original source