Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
アプリ道場サロン 第1回LTスライド
Search
Nekokichi
January 27, 2021
Programming
62
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
アプリ道場サロン 第1回LTスライド
Swiftのローカル通知をバックグラウンドに対応
Nekokichi
January 27, 2021
More Decks by Nekokichi
See All by Nekokichi
VSCodeの練習用スライド
neokokichi
0
43
未経験からのエンジニア転職
neokokichi
0
40
Other Decks in Programming
See All in Programming
Performance Optimization With LLMs
xleitix
0
140
ActionController meets Protocol Buffers
sorah
0
560
sbt 2.0: takeoff
eed3si9n
0
160
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
APNsからLive Activityを開始する話
yumnumm
0
170
Event is what happens
moro
2
860
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
残高管理から台帳サービスへの進化
artoy
1
200
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
980
AmebaブログはKMPから卒業します
kmars0605
0
200
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
Side Projects
sachag
456
43k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
420
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Un-Boring Meetings
codingconduct
0
460
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Transcript
ϩʔΧϧ௨ͷॲཧΛ όοΫάϥϯυʹରԠͯ͠Έͨ !OFLPLJDIJ@ZPT
ࣗݾհ w/FLPLJDIJʢ!OFLPLJDIJ@ZPTʣ wΤϯδχΞब׆ͯ͠·͢ wॳΊͯͷ-5
ϩʔΧϧ௨ͱ w σόΠε্Ͱ݁ w ࣅͨͷͰɺϓογϡ௨ w τϦΨʔʢ˓ඵޙɺɺҐஔใʣ
func setupUNNotification() { // ௨༰ let content = UNMutableNotificationContent() content.sound
= .default content.title = "௨Λड৴" content.body = "f2fwegewgewgewgewg" // 3ඵޙʹ௨ let timeIntervalTrigger = UNTimeIntervalNotificationTrigger(timeInterval: 3, repeats: false) // ௨ͷϦΫΤετ let request = UNNotificationRequest(identifier: UNNotificationValues.localNotificationIdentifier, content: content, trigger: timeIntervalTrigger) // ௨Λొ let center = UNUserNotificationCenter.current() center.add(request) { (error: Error?) in if let error = error { print(error.localizedDescription) } } } ϩʔΧϧ௨ͷ࡞
extension AppDelegate: UNUserNotificationCenterDelegate { // ΞϓϦ্(ϑΥΞάϥϯυ)Ͱ௨Λड৴ͨ͠߹ func userNotificationCenter( _ center:
UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {} // ௨Λλοϓͨ͠߹ func userNotificationCenter( _ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {} } ϩʔΧϧ௨ͷϝιου
·ͩෆे
ͷγʔϯ
Կ͕͔ʁ ΞϓϦΛ։͘ ௨ͷॲཧ ௨ͷ σϦήʔτϝιου ௨ͷॲཧ ❓
खॱ w ΞϓϦىಈΛݕ w ௨Λऔಘ͔ͨ͠ΛνΣοΫ
func sceneDidBecomeActive(_ scene: UIScene) { // ௨͞Εͨ௨Λશͯऔಘ // notifications:[UNNotification] UNUserNotificationCenter.current().getDeliveredNotifications
{ (notifications) in if !notifications.isEmpty { for notification in notifications { // ϩʔΧϧ௨ͷϓϩύςΟΛऔΓग़ͤΔ print(notification.request.identifier) print(notification.request.content.title) print(notification.request.content.body) } } // ड৴ॲཧ͕ྃͨ͠ͷͰআ UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ["ϩʔΧϧ௨ͷidenfier"]) } }
func sceneWillEnterForeground(_ scene: UIScene) { // ௨͞Εͨ௨Λશͯऔಘ // notifications:[UNNotification] UNUserNotificationCenter.current().getDeliveredNotifications
{ (notifications) in if !notifications.isEmpty { for notification in notifications { // ϩʔΧϧ௨ͷϓϩύςΟΛऔΓग़ͤΔ print(notification.request.identifier) print(notification.request.content.title) print(notification.request.content.body) } } // ड৴ॲཧ͕ྃͨ͠ͷͰআ UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ["ϩʔΧϧ௨ͷidenfier"]) } }
ཱͭ໘ wΞϥʔτΛදࣔ wΠϕϯτ௨ͰผϑΝΠϧͷॲཧ
·ͱΊ w ϩʔΧϧ௨ΛόοΫάϥϯυʹରԠ w TDFOF%FMFHBUFͷϝιουͰΞϓϦͷىಈΛݕ w HFU%FMJWFSFE/PUJGJDBUJPOT Ͱड৴͞Εͨ௨Λऔಘ
2JJUB ϒϩά 5XJUUFS ϑΥϩʔΑΖ͓͘͠ئ͍͠·͢
͝ਗ਼ௌɺ͋Γ͕ͱ͏͍͟͝·ͨ͠