Reputation: 19790
I've just implemented background fetch in my iOS app. I implemented this method in my app delegate:
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
The correct way of implementing this is to call completionHandler(UIBackgroundFetchResultNewData)
when there is new data, and completionHandler(UIBackgroundFetchResultNoData)
when there's nothing new to download.
However, not all web services can give this information. Some of them just require the developers to fetch new data all the time even though there is nothing new. In this case, what will be the downside of calling completionHandler(UIBackgroundFetchResultNewData)
at every background fetch?
Upvotes: 0
Views: 224
Reputation: 39470
One side effect of calling completionHandler(UIBackgroundFetchResultNewData)
is that a snapshot of the UI is taken so that when the user switches back to your app the UI is immediately updated.
Depending on how often you fetch data and how likely it is (or isn't) to be new, this could result in some moderate performance hits due to the unnecessary capture and save of snapshots in the cache. If your app is already pushing the boundaries of performance and battery usage it may be worth investigating making changes on the web services side.
Upvotes: 2