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
もう怖くないバックグラウンド処理 Background Tasks のすべて - Hakoda...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Kanta Oikawa
February 22, 2026
Technology
450
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
もう怖くないバックグラウンド処理 Background Tasks のすべて - Hakodate.swift #1
Hakodate.swift #1 LT
Kanta Oikawa
February 22, 2026
More Decks by Kanta Oikawa
See All by Kanta Oikawa
2027年のMetricKit
kantacky
0
130
はじめてのCoreSpotlight
kantacky
0
120
ヘッドジェスチャを検知して Vibe Cooking - iOSDC Japan 2025
kantacky
0
670
Other Decks in Technology
See All in Technology
Agent 時代の Kaggle 展望 / kaggle-in-the-agentic-era
upura
1
850
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
19k
Bits Agent Builder の⼊⾨と活⽤事例
nulabinc
PRO
0
250
トヨタ⽣産⽅式(TPS)⼊⾨
recruitengineers
PRO
3
1.1k
35分でわかるEffective Platform Engineering
nwiizo
5
520
強化学習「理論」入門
enakai00
3
3.6k
属人化を叩き割れ!「制作加速」と「安定化」の矛盾を打破する:8年目プロダクトが辿り着いた「ミスが起こり得ない」アセット制作フローの全貌
gree_tech
PRO
0
110
2026-08-15 JAWS-UG 茨城 #16 Secrets ManagerにおけるSecret値の管理(Terraformの場合) / Secrets Manager Secrets
masasuzu
0
360
Apache Icebergインフラストラクチャ:ストレージ・カタログ・エンジンの選択肢とClouderaプラットフォームでの実装
tsugiyama
0
120
社内の7割が使うデータ基盤を、 データチーム2人で回すためにやったこと
koh_yoshi
4
1.5k
JavaScript 研修 (2026)
recruitengineers
PRO
2
660
AIペネトレーションテスト・ セキュリティ検証「AgenticSec」紹介資料
laysakura
2
9.3k
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
970
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
460
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
220
We Are The Robots
honzajavorek
0
300
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
660
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
66
57k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Embracing the Ebb and Flow
colly
88
5.1k
Transcript
Kanta Oikawa - 2026/02/22 ͏ා͘ͳ͍όοΫάϥϯυॲཧ Background Tasks ͷͯ͢ Hakodate.swift #1
LT
όοΫάϥϯυॲཧා͍ɺ͚Ͳେࣄ • iOSͷόοΫάϥϯυॲཧ੍͕ଟͯ͘େมͦ͏ • σόοά͕େมͦ͏ • ͰɺϢʔβʔମݧΛ্ͤ͞ΔͨΊʹආ͚ΒΕͳ͍͜ͱ • ۩ମతͳ੍ =
όοΫάϥϯυॲཧΛ࣮ߦ͢Δํ๏ • σόοάͷํ๏ • ͞Βͬͱ5Ͱ… 2
3
4
5
6
όοΫάϥϯυॲཧͷछྨͱํ๏ • Background ͰॲཧΛ։࢝͢Δ • App Refresh (BGAppRefreshTask) • Background
Push Noti fi cation • Processing (BGProcessingTask) • Foreground Ͱ։࢝ͨ͠ॲཧΛ Background Ͱܧଓ͢Δ • UIApplication / beginBackgroundTask(expirationHandler:) • BGContinuedProcessingTask (26+) 7
Background ͰॲཧΛ։࢝͢Δ App Refresh (BGAppRefreshTask) • e.g. גՁΞϓϦͰ࠷৽ͷגՁΛऔಘ • සൟʹΞΫηε͢ΔσʔλΛ࠷৽ͷঢ়ଶʹอͭ
• ࣮ߦλΠϛϯάΞϓϦͷ༻ύλʔϯʹԠͯ͡γεςϜ͕ܾఆ • "࣍ճ࣮ߦ·Ͱͷ࠷খ࣌ؒ" ͷΈίϯτϩʔϧՄೳ 8
Background ͰॲཧΛ։࢝͢Δ Background Push Noti fi cation • e.g. χϡʔεΞϓϦͷใهࣄ
• ཁ͢Δʹ Remote Push Noti fi cation • Push ϕʔεͰσʔλΛߋ৽ App Refresh Fetch ϕʔεͰσʔλΛߋ৽ • Push Noti fi cation Λड͚औͬͨޙͷॲཧ͕ଈ࣮࣌ߦ͞ΕΔอূͳ͍ 9
Background ͰॲཧΛ։࢝͢Δ Processing (BGProcessingTask) • e.g. σʔλϕʔεͷཧ • Ϣʔβʔ͕σόΠεΛ༻͍ͯ͠ͳ͍ؒʹ࣮ߦ͞ΕΔ •
Ϣʔβʔ͕σόΠεͷ༻Λ࢝ΊΔͱఀࢭ͞ΕΔ • ͔͔Δॲཧ࣮ߦͰ͖Δ͕ɺγεςϜʹΑΓதஅ͞ΕΔՄೳੑ͕͋Δ • ωοτϫʔΫଓঢ়ଶɺిݯଓঢ়ଶΛ࣮ߦ݅ͱͯ͠ࢦఆͰ͖Δ 10
Foreground Ͱ։࢝ͨ͠ॲཧΛ Background Ͱܧଓ͢Δ UIApplication / beginBackgroundTask(expirationHandler:) • e.g. ঢ়ଶͷมߋ,
σʔλϕʔεͷஅ • γεςϜ͕։࢝ͨ͠ॲཧΛɺ BackgroundʹભҠͯ͠ܧଓͯྃͤ͠͞Δ 11
Foreground Ͱ։࢝ͨ͠ॲཧΛ Background Ͱܧଓ͢Δ BGContinuedProcessingTask (26+) • e.g. InstagramͷετʔϦʔΛߘ •
Ϣʔβʔ͕։࢝ͨ͠ॲཧΛBackgroundʹભҠͯ͠ܧଓͯྃͤ͠͞Δ • ਐḿ͕Live ActivityͰදࣔ͞ΕΔ 12
Background Tasks ͷϑϩʔνϟʔτ 13
όοΫάϥϯυॲཧΛ࣮ߦ Background Modes Λ༗ޮԽ 14
όοΫάϥϯυॲཧΛ࣮ߦ Task ID Λ Info.plist ʹొ 15
όοΫάϥϯυॲཧΛ࣮ߦ (App Refresh, Processing) Task ID Λࢦఆͯ͠λεΫΛεέδϡʔϧ private func scheduleAppRefresh()
{ let request = BGAppRefreshTaskRequest(identifier: appRefreshTaskIdentifier) request.earliestBeginDate = Date(timeIntervalSinceNow: 15 * 60) do { try BGTaskScheduler.shared.submit(request) print("Scheduled app refresh successfully") } catch { print("Failed to schedule app refresh: \(error)") } } 16
App Refresh ͱ Processing Λσόοά 1. Xcode Ͱ Run Destination
ʹ࣮ػΛબ 2. Run ͯ͠λεΫΛεέδϡʔϧ 3. Foreground Ͱ Pause program execution ϘλϯΛԡ͢ 4. Home Screen ʹΔͳͲͯ͠ Background ʹભҠͤ͞Δ 5. LLDBͰҎԼΛ࣮ߦʢൃՐ͍ͤͨ͞λεΫͷTask IDΛࢦఆ͢Δʣ e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdenti fi er:@"com.kantacky.BackgroundTasksSample .refresh"] 17
࣮ࡍʹͬͯΈͨ ࣮ • 2/20·Ͱͷ1िؒ͘Β͍Ͱ Vibe Coding ͯ͠৹ࠪʹఏग़ͨ͠ΞϓϦ • RSS ϑΟʔυϦʔμʔ
• App RefreshͰϑΟʔυΛFetchͯ͠৽ணهࣄΛϩʔΧϧ௨ 18
࣮ࡍʹͬͯΈͨ ͱղܾࡦ • ӡΑ۪͘ʹ࣮ߦ͞Εͯɺ࣍ճ࣮ߦ·Ͱͷ࠷খ࣌ؒ͝ͱʹ௨͕དྷͯ͏͍͟ • ࣍ճ࣮ߦ·Ͱͷ࠷খ࣌ؒΛେ͖͘͢Δɺ௨ରΛߜΔ • Background Push Noti
fi cation Λ͏ • αʔόʔͰϑΟʔυΛFetchͯ͠ɺ৽ணهࣄΛϦϞʔτ௨ • ௨ΛఘΊͯɺApp RefreshͰϑΟʔυΛ࠷৽ͷঢ়ଶʹอ͚ͭͩʹͱͲΊΔ 19
Materials https://kantacky.com/hakodate-swift-1 • εϥΠυ • https://speakerdeck.com/kantacky/hakodate-swift-1 • App RefreshΛ࣮ͨ͠αϯϓϧίʔυ •
https://github.com/kantacky/background-tasks-ios 20
Kanta Oikawa • ެཱͩͯ͜ະདྷେֶ M1 • Έͳ͞ΜɺവؗʹΑ͏ͦ͜ʂ • ͥͻຬ٤͍͍ͯͬͯͩ͘͠͞ 21