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
400
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
ヘッドジェスチャを検知して Vibe Cooking - iOSDC Japan 2025
kantacky
0
600
Other Decks in Technology
See All in Technology
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
830
タクシーアプリ『GO』の実践的データ活用
mot_techtalk
3
190
AIっぽい文章を採点して人間らしく直すアプリを作ってみた
yama3133
2
120
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
770
失敗を経て、Harness Engineering で 大切にしたいことを考える / Learning from Failure: What Matters in Harness Engineering
bitkey
PRO
1
300
チームで進めるAI駆動アジャイル×ウォーターフォール
kumaiu
0
150
Android の公式 Skill / Android skills
yanzm
0
120
地球に⽣きるAI —GeoAIと「中間領域」— / AI Living on Earth — GeoAI and the “Intermediate Layer” —
ykiyota
0
280
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
530
日本 Fintech 未来予測レポート 2027〜2028年(手動編集版)
8maki
0
1.7k
Agentic Web
dynamis
1
200
MIERUNE JCT 発表資料「宇宙から伊能忠敬ごっこ」
syuchimu
0
210
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
A Modern Web Designer's Workflow
chriscoyier
698
190k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Everyday Curiosity
cassininazir
0
230
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
200
Raft: Consensus for Rubyists
vanstee
141
7.5k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
200
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
360
Visualization
eitanlees
152
17k
A designer walks into a library…
pauljervisheath
211
24k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
570
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