Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the different between background task and background fetch correctly?

I am looking at some document on the web about background task and background fetch.

Background task is a task which performance at the background while the app still running. When the app is in the background, the task have a limited time to get the task done, once it's fully background, the task have to be ended as well.

Background Fetch is the where the application is fully in background or inactive, the action will be scheduled to be executed at some point in time if the resources available.

This was my very brief understanding.

like image 247
LittleFunny Avatar asked May 29 '17 09:05

LittleFunny


People also ask

What is background fetch?

The Background Fetch API provides a method for managing downloads that may take a significant amount of time such as movies, audio files, and software.

What is background fetch in Swift?

Background fetch will let your app run in the background for about 30 seconds at scheduled intervals. The goal of this is to fetch data and prepare your UI for when the app runs next. Push notifications let your app fetch fresh data from your server.

Does background fetch work when app is terminated?

The Background Fetching will NOT happen in your app after the user has killed it in the multitasking UI. This is by design.


1 Answers

Yes, your understanding is right! Let me explain more deeply!

Background task is the ability to work continue in background.

For example if you are playing audio and you press home button then audio can continue play in background. same for location! you can continuously update location in background. This is just example there is many more type that works in background. You can say this kind of stuff as background task. A task that can continue work in background mode called background task.

You can refer Apple doc to know which kind of background tasks you can perform or allowed by iOS. Now background fetch is totally different thing. It is ability to check for new content or perform operation periodically if your application is in background or in inactive state. System automatically wake up your app in background when it is possible and can perform some operation. For example you can say facebook. Facebook have timeline which should have new data periodically, so it can use background fetch to fetch data from server, no matter if application is inactive! So, when user open the application he/she can get best user experiance because content are already downloaded by background fetch!

You can refer Apple doc for background fetch! It states,

Apps that need to check for new content periodically can ask the system to wake them up so that they can initiate a fetch operation for that content. To support this mode, enable the Background fetch option from the Background modes section of the Capabilities tab in your Xcode project. (You can also enable this support by including the UIBackgroundModes key with the fetch value in your app’s Info.plist file.) Enabling this mode is not a guarantee that the system will give your app any time to perform background fetches. The system must balance your app’s need to fetch content with the needs of other apps and the system itself. After assessing that information, the system gives time to apps when there are good opportunities to do so.

like image 144
Ketan Parmar Avatar answered Oct 05 '22 01:10

Ketan Parmar