Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
While Your App is Sleeping
Search
Gwendolyn Weston
September 08, 2015
Technology
650
3
Share
While Your App is Sleeping
Gwendolyn Weston
September 08, 2015
More Decks by Gwendolyn Weston
See All by Gwendolyn Weston
Keep Calm and Type Erase On
gwengrid
3
25k
Other Decks in Technology
See All in Technology
Pythonでベイズモデリング
soogie
0
180
はじめてのAI-DLC
yoshidashingo
2
470
TSKaigi 2026 - enumよ、さようなら
teamlab
PRO
3
480
The Making of AI Chips
pfn
PRO
0
710
コーディングエージェントはTypeScriptの 型エラーをどう自己修正しているのか
melonps
4
440
実例から学ぶ GuardDuty(SSH BruteForce)調査の全体フローと勘所【SecurityJAWS】
cscengineer
PRO
1
210
AI全盛の今だからこそ、あえてもう一度振り返るAPIの基礎
smt7174
3
160
ソフトウェアサプライチェーン攻撃対策として今からサクッとできること
flatt_security
2
120
CloudFront VPCオリジンとVPC Latticeサービスの内部ALBをマルチアカウントで一元利用しよう
duelist2020jp
5
200
サプライチェーン攻撃への備えについて考えている #湘なんか
stefafafan
3
2.3k
JaSSTに関わることで変わった人生観 #jasstnano
makky_tyuyan
0
180
Claude Code で使える DuckDB Skills を試してみた / DuckDB Skills and Claude Code
masahirokawahara
2
2.2k
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
The Language of Interfaces
destraynor
162
26k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
580
Thoughts on Productivity
jonyablonski
76
5.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Become a Pro
speakerdeck
PRO
31
5.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Odyssey Design
rkendrick25
PRO
2
620
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
200
RailsConf 2023
tenderlove
30
1.4k
Transcript
While Your App Was Sleeping Gwendolyn Weston @purpleyay
Background Transfer Services allows uploading or downloading requests to continue
on after app is terminated
Motivation
A Teakettle • That requires you to stand near it
• As well as continue to watch in order for it to boil water
Where can this happen in our apps?
PlanGrid
To guarantee download completion • Users would have to change
their settings so that the device never locks • Stay on the app
Downloading without Background Transfer Services is like watching water boil.
Overview • How to download in the foreground • How
to make that request background compatible • How to navigate common pitfalls
Downloading in the foreground
Downloading in Foreground
Downloading in Foreground NSURLSession: vends and manages requests
Downloading in Foreground sharedSession: singleton session with default settings
Downloading in Foreground NSURLSessionDownloadTask: the request
NSURLSessionTask • NSURLSessionDownloadTask • NSURLSessionUploadTask • NSURLSessionDataTask - short-lived requests
(not background compatible!)
We get tasks by feeding our session URLs
Cookie Monster as NSURLSession
None
Downloading in Foreground
Downloading in Foreground
Downloading in Foreground
Downloading in Foreground
Downloading in the background
Downloading in Foreground
None
NSURLSessionConfiguration: defines request behaviour and policies
None
Identifiers must be unique!
“I’m done downloading!!! Wake up!” application: handleEventsForBackgroundURLSession: completionHandler “It’s me,
the session called waterBoiling Session!”
None
!!Must!! re-instantiate session with identifier or delegate methods for request
will not get called.
“The behavior of multiple sessions sharing the same identifier is
undefined.”
Downloading in Background
None
Downloading in Background
“Completion handler blocks are not supported in background sessions”
Pitfall no completion handlers
Downloading in Background
“I’m done downloading!!! Wake up!” URLSession:downloadTask:didFinishDownloadingTo URL: “It’s me, the
request for task 42 in the session called boilingWaterSession!”
The delegate!
Downloading in Background
None
Downloading in Background
Pitfall No auxiliary request info
Promising… ?
Nope.
Subclasses?
None
Downloading in Background
“Can I have—“ “No.” “Just one subclass—“ “No.” NSURLSession
Persistence!
Downloading in Background
YUSS.
Questions? @purpleyay