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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
システムは「動く」だけでは 足りない - 非機能要件・分散システム・トレードオフの基礎
nwiizo
17
5.3k
Claude Teamプランの選定と、できること/できないこと
rfdnxbro
1
1.8k
建設的な現実逃避のしかた / How to practice constructive escapism
pauli
4
290
🀄️ on swiftc
giginet
PRO
0
200
ある製造業の会社全体のAI化に1エンジニアが挑んだ話
kitami
2
470
Strands Agents × Amazon Bedrock AgentCoreで パーソナルAIエージェントを作ろう
yokomachi
2
260
自己組織化を試される緑茶ハイを求めて、今日も全力であそんで学ぼう / Self-Organization and Shochu Green Tea
naitosatoshi
0
290
推し活エージェント
yuntan_t
1
880
インフラを Excel 管理していた組織が 3 ヶ月で IaC 化されるまで
geekplus_tech
3
130
Webアクセシビリティは“もしも”に備える設計
tomokusaba
0
170
Cortex Code君、今日から内製化支援担当ね。
coco_se
0
300
英語翻訳を通じて 音声AIエージェント入門してみた
shichijoyuhi
0
100
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
500
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
220
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.5k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
170
Optimizing for Happiness
mojombo
378
71k
For a Future-Friendly Web
brad_frost
183
10k
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