What is the different between background task and background fetch correctly?
Asked Answered
B

1

11

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.

Bromine answered 29/5, 2017 at 9:26 Comment(0)
M
13

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.

Morrissette answered 29/5, 2017 at 9:46 Comment(2)
If I am using Xamarin form, and using timer to schedule data receiving while the app is still active but in background. will this be similar to background task?Bromine
I don't have much idea about Xamarin but yes you can say it kind of background task!Morrissette

© 2022 - 2024 — McMap. All rights reserved.