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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With