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
Mode offline Cocoaheads
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Mathieu Hausherr
May 17, 2018
Technology
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Mode offline Cocoaheads
Mathieu Hausherr
May 17, 2018
More Decks by Mathieu Hausherr
See All by Mathieu Hausherr
Mobilis In Mobile 2024 - iOS, Android et la voiture - État des lieux
mhausherr
0
96
FrenchKit - Contact Tracing & Exposure Notification
mhausherr
0
220
FRAUG StopCovid19 : Le point sur les applications de tracing Bluetooth
mhausherr
1
280
Swift Lille - CoreML / CreateML
mhausherr
0
120
Image classification in real world : Car rental damage report
mhausherr
0
100
Les surcouches constructeur sur Android
mhausherr
1
900
Mode offline : Notre application Android fonctionne au niveau -5 d’un parking
mhausherr
0
1.5k
Mode offline : Notre application mobile fonctionne au niveau -5 d’un parking
mhausherr
1
150
CocoaHeads : Apple Pay
mhausherr
0
84
Other Decks in Technology
See All in Technology
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
5
1.8k
Building applications in the Gemini API family.
line_developers_tw
PRO
0
1.9k
もりもり新機能を一挙紹介! AgentCoreに入門して、AWS上にAIエージェントを構築しよう
minorun365
PRO
6
840
ABEMA の Datadog × OTel 基盤、 中から見るか? 外から見るか?
tetsuya28
0
110
Rubyで音を視る
ydah
1
100
Oracle AI Database@Google Cloud:サービス概要のご紹介
oracle4engineer
PRO
6
1.5k
Agentic ERPをどう設計するか ー 受発注エージェントを動かす、現場の知見と設計思想ー
recerqainc
1
1.7k
EventBridge Connection
_kensh
4
590
AI Testing Talks: Challenges of Applying AI in Software Testing: From Hype to Practical Use
exactpro
PRO
1
140
Agentic Defenseとともにセキュリティエンジニアが輝き続けるには / How Security Engineers Can Keep Excelling with Agentic Defense
yuj1osm
0
120
製造業のクラウド活用最適解〜AI,DXを加速するデータ基盤の作り方〜
hamadakoji
0
400
AIを「創る」と「使う」の循環 — HRテックが実践するリアルなAI組織実装
taketo957
0
1.7k
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
190
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
150
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
150
Typedesign – Prime Four
hannesfritz
42
3.1k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
550
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
210
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
380
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.7k
BBQ
matthewcrist
89
10k
Transcript
CocoaHeads Mathieu Hausherr @mhausherr 1 https://www.youtube.com/watch?v=wc38XyAA43o
Mode offline Notre application fonctionne au niveau -5 d’un parking
2
3
4
5
6
7
8
9
10
X
12
13
14
X Version 0.0.1-alpha
16
17 Plus jamais ça !
X Cache all requests if !isNetworkReachable && readFromCache(handler) { return
} manager.request(baseURL + path, method: method, parameters: parameters, encoding: encoding) .validate() .responseJSON { response in switch response.result { case .failure(let error): self.readFromCache(handler) case .success: self.writeResponseToCache(response: response) } }
X Cache all requests if !isNetworkReachable && readFromCache(handler) { return
} manager.request(baseURL + path, method: method, parameters: parameters, encoding: encoding) .validate() .responseJSON { response in switch response.result { case .failure(let error): self.readFromCache(handler) case .success: self.writeResponseToCache(response: response) } }
X Cache all requests if !isNetworkReachable && readFromCache(handler) { return
} manager.request(baseURL + path, method: method, parameters: parameters, encoding: encoding) .validate() .responseJSON { response in switch response.result { case .failure(let error): self.readFromCache(handler) case .success: self.writeResponseToCache(response: response) } }
X Cache all requests if !isNetworkReachable && readFromCache(handler) { return
} manager.request(baseURL + path, method: method, parameters: parameters, encoding: encoding) .validate() .responseJSON { response in switch response.result { case .failure(let error): self.readFromCache(handler) case .success: self.writeResponseToCache(response: response) } }
X Cache strategies switch cacheMode { case .standard: if !isNetworkReachable
&& readFromCache(handler) { return } case .forceCache: readFromCache(handler); return case .twoStepLoading: readFromCache(handler) }
X Cache strategies switch cacheMode { case .standard: if !isNetworkReachable
&& readFromCache(handler) { return } case .forceCache: readFromCache(handler); return case .twoStepLoading: readFromCache(handler) }
X Cache strategies switch cacheMode { case .standard: if !isNetworkReachable
&& readFromCache(handler) { return } case .forceCache: readFromCache(handler); return case .twoStepLoading: readFromCache(handler) }
X cache before call call cache after call standard forceCache
noCache twoStepLoading
X Cache Swift func getData() -> Data? { try? Data(contentsOf:
cacheURL) } func set(data: Data) { try? data.write(to: cacheURL, options: [.atomic]) } var isCacheStillValid: Bool { guard let attributes = try? FileManager.default.attributesOfItem(atPath: pathForCacheFile) else { return false } guard let modificationDate = attributes[FileAttributeKey.modificationDate] as? Date else { return false } return self.cacheDuration - modificationDate.timeIntervalSinceNow > 0 }
X Cache Swift func getData() -> Data? { try? Data(contentsOf:
cacheURL) } func set(data: Data) { try? data.write(to: cacheURL, options: [.atomic]) } var isCacheStillValid: Bool { guard let attributes = try? FileManager.default.attributesOfItem(atPath: pathForCacheFile) else { return false } guard let modificationDate = attributes[FileAttributeKey.modificationDate] as? Date else { return false } return self.cacheDuration - modificationDate.timeIntervalSinceNow > 0 }
X
29 Bien joué les gars !
X Version 1.0.0
31
X Déclaration la plus rapide possible, image avec sha256 POST
/inspection [{ "created_at": …, "zone_id": …, "image_hash": … }]
33
X Notifications silencieuses iOS <key>UIBackgroundModes</key> <array> <string>remote-notification</string> </array>
X Version 1.1.0
36
X
X
X
X Image cache Swift class ImageCache { var inMemoryCache: [URL:
UIImage] = [:] func image(forURL url: URL) -> UIImage? { if let image = inMemoryCache[url] { return image } if let image = readImageFromCache(url) { inMemoryCache[urlString] = image; return image } else { return nil } } }
X Premiers retours utilisateurs
42
X
X
X
X Version 2.7.0
X 400 voitures 250 000 téléchargements
X Pour tester
49 Merci