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
3
640
While Your App is Sleeping
Gwendolyn Weston
September 08, 2015
Tweet
Share
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
Japan AWS Jr. Championsがお届けするre:Invent2024のハイライト ~ラスベガスで見てきた景色~
fukuchiiinu
0
1.1k
例外処理を理解して、設計段階からエラーを「見つけやすく」「起こりにくく」する
kajitack
12
3.7k
消し忘れリソースゼロへ!私のResource Explorer活用法
cuorain
0
140
CNAPPから考えるAWSガバナンスの実践と最適化
yuobayashi
5
680
Microsoft Ignite 2024 最新情報!Microsoft 365 Agents SDK 概要 / Microsoft Ignite 2024 latest news Microsoft 365 Agents SDK overview
karamem0
0
190
Redmineの意外と知らない便利機能 (Redmine 6.0対応版)
vividtone
0
190
Zenn のウラガワ ~エンジニアのアウトプットを支える環境で Google Cloud が採用されているワケ~ #burikaigi #burikaigi_h
kongmingstrap
18
6.8k
CNAPPから考えるAWSガバナンスの実践と最適化
nrinetcom
PRO
1
330
GraphRAG: What I Thought I Knew (But Didn’t)
sashimimochi
1
230
生成AIを活用した機能を、顧客に提供するまでに乗り越えた『4つの壁』
toshiblues
1
210
Grafanaのvariables機能について
tiina
0
180
[JAWS-UG栃木]地方だからできたクラウドネイティブ事例大公開! / jawsug_tochigi_tachibana
biatunky
0
130
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
89
5.8k
Designing for humans not robots
tammielis
250
25k
What's in a price? How to price your products and services
michaelherold
244
12k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Become a Pro
speakerdeck
PRO
26
5.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
Embracing the Ebb and Flow
colly
84
4.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
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