Slide 1

Slide 1 text

No#fica#ons in iOS10 2016/07/21 @TachibanaKaoru

Slide 2

Slide 2 text

ࣗݾ঺հ ϑϦʔϥϯεͷiOSΤϯδχΞΛ͍ͯ͠· ͢ɻ (2016೥8݄͔Βʂ) • Twi%er: @TachibanaKaoru • Blog : h%p:/ /www.toyship.org/ • ϘϧμϦάϯ޷͖

Slide 3

Slide 3 text

What's new in No.fica.on of iOS • ௨஌ʹ"tle/sub"tle͕͚ͭΒΕΔΑ͏ʹͳͬͨ • ௨஌ʹΠϝʔδ΍ը૾͕͚ͭΒΕΔΑ͏ʹͳͬͨ • ௨஌ʹCustom UI͕͚ͭΒΕΔΑ͏ʹͳͬͨ • Ϣʔβʔ͕௨஌ΛڐՄ͔ͨ͠Ͳ͏͔ͷઃఆ͕ͱΕΔΑ͏ʹͳͬ ͨ • ഑৴ɾະ഑৴ͷ௨஌Λ؆୯ʹϋϯυϦϯάͰ͖ΔΑ͏ʹͳͬͨ

Slide 4

Slide 4 text

഑৴ɾະ഑৴ͷ௨஌Λ؆୯ʹϋϯυ ϦϯάͰ͖ΔΑ͏ʹͳͬͨ

Slide 5

Slide 5 text

Local No(fica(onͱRemote No(fica(on͕౷ Ұ͞Ε·ͨ͠ɻ

Slide 6

Slide 6 text

Remote No(fica(on { "aps" : { "alert" : { "title" : "Introduction to Notifications", "subtitle" : "Session 707", "body" : "Woah! These new notifications look amazing!" }, "badge" : 1 }, }

Slide 7

Slide 7 text

Local No(fica(on let center = UNUserNotificationCenter.current() let content = UNMutableNotificationContent() content.title = "Hello" content.body = "This is a big news!" content.sound = UNNotificationSound.default() let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 10, repeats: false) let request = UNNotificationRequest.init( identifier: "NewsUpdate", // ͜ͷIDΛΩʔʹͯ͠࡟আ΍ฤूΛ͠·͢ content: content, trigger: trigger) center.add(request)

Slide 8

Slide 8 text

௨஌ͷ؅ཧ ·ͣɺ௨஌ͷঢ়ଶʹ͸Լهͷ͕̏ͭ͋Γ·͢ɻ • Pending : ·ͩൃՐ͍ͯ͠ͳ͍௨஌ • Delivered : ൃՐ͕ͨ͠ɺϢʔβʔ͕ॲཧʢλοϓͳͲʣΛͯ͠ ͍ͳ͍௨஌ • (Read) : Ϣʔβʔ͕ॲཧΛͨ͠௨஌ɹʢ͜ͷঢ়ଶͷ௨஌͸औಘͰ ͖·ͤΜɻʣ

Slide 9

Slide 9 text

௨஌ͷঢ়ଶભҠ • ొ࿥͞Εͨ௨஌͸ɺPendingঢ়ଶͱͳΔ • τϦΨʔΠϕϯτʢ࣌ؒ΍ҐஔͳͲʣʹΑΓൃՐͯ͠Delivered ঢ়ଶͱͳΔ • Ϣʔβʔ͕ॲཧΛ͢ΔͱReadͱͳΓɺ UNUserNo2fica2onCenter͔Β͸औಘͰ͖ͳ͘ͳΔ

Slide 10

Slide 10 text

get pending no*fica*ons UNUserNotificationCenter.current().getPendingNotificationRequests { requests in print("== Pending Notification : \(requests.count) == ") for request in requests { request.identifier request.content.title request.content.subtitle request.content.body request.trigger print(" -- title : \(request.content.title) body:\(request.content.body)") } }

Slide 11

Slide 11 text

delete pending no+fica+ons //ಛఆͷpending௨஌Λফ͢ UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: ["NewsUpdate","NewsDelivery"]) //શ෦ͷpending௨஌Λফ͢ UNUserNotificationCenter.current().removeAllPendingNotificationRequests()

Slide 12

Slide 12 text

update pending no,fica,ons // ৽͍͠contentΛͭ͘Δ let content = UNMutableNotificationContent() content.title = "Hello" content.body = "This is a more big news!" content.sound = UNNotificationSound.default() let trigger = UNTimeIntervalNotificationTrigger.init(timeInterval: 5, repeats: false) // ৽͍͠requestΛͭ͘Δ let newRequest = UNNotificationRequest.init(identifier: "NewsUpdate", content: content, trigger: trigger) // ৽͍͠requestΛͭ͘Δʢݹ͍΋ͷΛdelete͢Δඞཁ͸ͳ͍ʣ UNUserNotificationCenter.current().add(newRequest) { error in // error }

Slide 13

Slide 13 text

get delivered no,fica,ons UNUserNotificationCenter.current().getDeliveredNotifications { notifications in // [UNNotification]) print("== Delivred Notification : \(notifications.count) == ") for notification in notifications { notification.date notification.request print(" -- title : \(notification.request.content.title) body:\(notification.request.content.body) date: \(notification.date)") } }

Slide 14

Slide 14 text

delete delivered no+fica+ons //ಛఆͷdeliver͞Εͨ௨஌Λফ͢ UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ["NewsUpdate","NewsDelivery"]) //શ෦ͷdeliver͞Εͨ௨஌Λফ͢ UNUserNotificationCenter.current().removeAllDeliveredNotifications()

Slide 15

Slide 15 text

No#fica#on in ac#on • ΞϓϦ͕ Foregroundʹ͋Δঢ়ଶͰ௨஌͕഑৴͞Εͨ৔߹ʹɺγ εςϜͷ௨஌ը໘ΛͩͤΔΑ͏ʹͳΓ·ͨ͠ɻ func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { print("! Notification came!\(notification.request.content.title)") completionHandler([.alert, .sound])// ͜ΕΛ͍Ε͓ͯ͘ͱɺγεςϜͷ௨஌ը໘Λͩͯ͘͠ΕΔ }

Slide 16

Slide 16 text

iOS9ͱiOS10ͷ௨஌ϋϯυϦϯάͷҧ͍ • Fav௨஌ • iOS9·Ͱ͸ɺFav͞ΕΔͨͼʹ௨஌͕͘ΔͷͰɺ௨஌ཝ͕ಛ ఆͷtweetͷFav௨஌Ͱ͏·ͬͯ͠·ͬͨ • iOS10Ͱ͸ɺFav͞ΕΔͨͼʹ௨஌Λߋ৽͢ΔͨΊɺಛఆͷ tweetͷFav௨஌͸ৗʹҰͭ

Slide 17

Slide 17 text

iOS9ͱiOS10ͷ௨஌ϋϯυϦϯάͷҧ͍ • ίϝϯτ௨஌ • iOS9·Ͱ͸ɺίϝϯτ͕ͭͨ͘ͼʹ௨஌Λૹ͍ͬͯͨͨΊɺ ΋Γ͕͍͋ͬͯΔεϨουͷίϝϯτ௨஌Ͱ͏·ͬͯ͠·ͬ ͨ • iOS10Ͱ͸ɺίϝϯτ͕ͭͨ͘ͼʹ௨஌Λߋ৽͢ΔͨΊɺಛ ఆͷεϨουͷ௨஌͸ৗʹҰͭ

Slide 18

Slide 18 text

·ͱΊ • iOS10Ͱ͸௨஌ͷ಺༰Λมߋ͢Δ͜ͱ͕Ͱ͖ΔΑ͏ʹͳͬͨͨ Ίɺॊೈͳ௨஌ઃܭ͕Ͱ͖ΔΑ͏ʹͳΓ·ͨ͠ • ແବͳ௨஌Λ;΍ͣ͞ɺ͢Ͱʹ͋Δ௨஌Λߋ৽͠Α͏ • ΞϓϦ಺௨஌ͰɺγεςϜ௨஌ը໘Λදࣔ͠Α͏