
Apple iOS Background Tasks - reimertz
https://developer.apple.com/documentation/backgroundtasks
======
trixie_
Background tasks are partly to blame for a device's performance degradation
over time - see Windows and Android devices. I have more apps than anyone on
my iPhone and the performance is still great. I can just imagine if all the
stupid games I download were trying to run background tasks as well. I hope
Apple lets us control what apps have permission to do this. Also I hope 'low
power mode' auto-disables background tasks. Developers are going to take
advantage of this in a way that often will not benefit the user.

~~~
joemag
Frankly, looking at all my apps, the only use-case I have for background tasks
is Google Photos, who I want to automatically upload my recent photos to the
cloud. A very distant second would be communication apps running some kind of
reconciliation once or twice a day, in case some notifications were missed.

I have no desires for any of my other apps to execute any tasks in the
background.

~~~
krtkush
IMO, any app that needs to download file sin background needs this. Audible
and Pocket Casts for me personally because there are times when I want to
download files for offline use and I have to keep the app open till the
download is not complete.

~~~
pjscott
On Apple's platforms you can get this with a background NSURLSession. It lets
you express concepts like "Download this URL at a convenient time, preferably
when the device is plugged in and connected to Wifi" or "Start downloading
this now, but keep going even after this app is closed."

It's definitely more work to figure out than regular foreground URL fetching,
though.

[https://developer.apple.com/documentation/foundation/url_loa...](https://developer.apple.com/documentation/foundation/url_loading_system/downloading_files_in_the_background?language=objc)

------
omni
If Spotify doesn't finally use this to download songs without requiring me to
open the app then I'm going to riot

~~~
p2t2p
I stopped using Spotify exactly because quality of their apps is just not
acceptable.

~~~
asdfasgasdgasdg
On iOS? This feature is new in iOS 13, so there was no way Spotify could have
offered this capability before, right? Of course, there is no such limitation
for Apple's apps.

~~~
p2t2p
I'm not complaining about this feature, I'm talking about overall feeling of
their priorities. It took them ages to have an Apple Watch up with folks like
VOX had it no time. Their priorities are unclear, highly voted feature take
ages to appear in the apps, the apps itself look like compromise and attempt
to save on developers and reuse as much of web version as possible. It just
doesn't feel like a carefully designed experience. I'm not saying Apple Music
is perfect or anybody else, I just choose the less annoying thing for myself.

~~~
consistency
They made a site to explain this:
[https://timetoplayfair.com/timeline/](https://timetoplayfair.com/timeline/).

------
reimertz
"A request to launch your app in the background to execute a processing task
that can take minutes to complete."

Compared to the previous limit of 15 seconds, it's a pretty substantial
change.

It seems you need to request it appropriate permissions though, so it's
probably going to work similarly to how Background Fetch worked. If your app
is used very seldom, your script might be running less frequent then you
request.

~~~
alvatech
So the limit is increased to 1 minute? Is it possible to run a continuous task
in the background (like foreground task in Android)?

~~~
rishabhparikh
It is possible, but not by default. Your app must request additional
permissions for indefinite background execution. It's quite difficult to get
your app approved with said permission.

~~~
BoorishBears
What permission is that?

~~~
NegativeLatency
Looks like it’s related to the stated use case of the app
[https://stackoverflow.com/a/11044108](https://stackoverflow.com/a/11044108)

------
kccqzy
As a user I'm going to turn this off as soon as possible. The background app
refresh feature is widely misused by app developers for tracking purposes, and
it destroys battery life. I see no drawback when apps can't do things in the
background. Maybe you'll now have to wait a few extra seconds for your mail
app to download your latest mail or for your weather app to fetch the latest
weather. It's really no big deal.

Of course this is my particular personal preference. YMMV.

~~~
xenospn
Some apps depend on location information and that can change when the app
isn’t running (think alert system or apps that track stuff). But even for
these, I don’t see why they can’t wake up and go back to sleep after 5
seconds, and leave all the heavy lifting to a server in the cloud that can
send a notification if anything more serious is necessary.

~~~
csunbird
Those apps can use geofencing API for these purposes.

~~~
xenospn
Not if the phone needs to update while it's location hasn't changed.

------
keyle
As a developer I can't believe this wasn't a thing already. As a user, I'm
scared of it being abused / misused. And I trust myself more as a user than
the average guy as a developer!

------
orev
Hopefully this allows real alarm clock type apps that you don’t have to have
in the foreground. But reading the description I’m not sure that’s the
purpose.

------
harshaw
I haven't been an IOS developer in year but there used to be (in the IOS7
days) a way to run some limited tasks in the background, especially to handle
push notifications IIRC. Sounds like this is an improvement - but isn't this
years and years overdue? I assume this is trivial on Android.

~~~
isatty
And I’m also sure it’s abused to heck on Android.

~~~
kkarakk
Oreo added limits on background execution and they're going to further tighten
the screws later. it doesn't even matter actually as the way OEMs implement
killing apps to save battery if all unique(for eg huge rams aren't even used
on xiaomi devices as the task scheduler will kill any apps above the limit of
6)

------
cordite
Oh, will this finally fix youtube uploading on mobile?

~~~
bithavoc
Apps are able to upload and download in background with iOS 12 by telling iOS
to upload or download it for you and wake up the app once the upload is
done(failed or succeeded). It even retries on connection fails, etc. It's
called Background Transfer Services

------
adrr
Couldn’t you do this with silent push notifications that you could use to make
the app download new content?

~~~
dangwu
That kind of work is more on the order of seconds - not minutes. And it
obviously requires a service-side component (push notifications) while this
doesn’t.

------
ozgung
Does anyone know if we can use GPU (metal) with this new API. It wasn’t
possible before.

~~~
saagarjha
Not sure, but they give examples of training machine learning models in the
background when connected to power, so it's quite likely.

------
Veen
I wonder if this is the mechanism used by the new Shortcuts time triggers.

------
hprotagonist
This could be handy for things like
cronios([https://routinehub.co/shortcut/1267](https://routinehub.co/shortcut/1267))
which really spiffs up Shortcuts.

~~~
akmarinov
No need, that’s now baked into the Shortucts app itself.

~~~
p2t2p
I'm really keen on getting my hands on it. I have a shortcut that downloads
videos from youtube and puts them into a folder. If I to be able to have a
shortcut that does in in background while my phone is charging, that would be
amazing.

------
rolltiide
Can anyone from Apple chime in about the vetting process which results in
Apple releasing features 5-8 years behind similar offerings, when it isn't the
first?

~~~
illumin8
Not from Apple, just a happy customer.

I'm actually thankful that Apple forces developers to respect my battery life.
Battery life on Android has been a shit-show for years because any app can
burn your battery down by constantly downloading who knows what in the
background (probably ads).

~~~
joemag
That was the single biggest difference I observed when I switched from Android
to Apple 4 years ago. I no longer had periodic episodes where my phone would
burn through 80% of my battery in 30 minutes, while getting lava hot. Not sure
if Android has figured background tasks in the last 4 years, but the
inconvenience of not having background tasks was greatly outweighed by having
predictable battery life and performance.

