$30 off During Our Annual Pro Sale. View Details »

20170130 NotificationContent Extensionを使ってみた

Kei Ito
January 30, 2017

20170130 NotificationContent Extensionを使ってみた

関モバ #22の資料です

Kei Ito

January 30, 2017
Tweet

More Decks by Kei Ito

Other Decks in Programming

Transcript

  1. /PUJpDBUJPO$POUFOU &YUFOTJPOΛ࢖ͬͯΈͨ ؔ੢ϞόΠϧΞϓϦݚڀձ !JUPL@UXJU

  2. !JUPL@UXJU w ͍ͱ͏͚͍ʢJUPLʣ w ɹɹɹɹɹɹͷதͷਓ w ެࢲڞʹϓϩάϥϚJ04.BDʢͨ·ʹ"OESPJE΍8JOEPXTʣ w IUUQJUPLKQ IUUQTPSBLB[FDPKQ

  3. /PUJpDBUJPO$POUFOU &YUFOTJPOͱ͸

  4. දࣔͰ͖Δ΋ͷ w ී௨ͷ6*ίϯςϯπͳΒ͍͍ͩͨԿͰ΋

  5. 6*8FC7JFX

  6. .,.BQ7JFX

  7. ΍ͬͯΈΑ͏ 9DPEFJ04 ϦϞʔτ௨஌

  8. 5BSHFUΛ௥Ճ

  9. *OGPQMJTUͷฤू

  10. 6//PUJpDBUJPO&YUFOTJPO $BUFHPSZ w ඞਢ w ௨஌ૹ৴ଆͰ͜ΕΛࢦఆ w $BUFHPSZ͕Ұகͨ͠৔߹ͷΈ&YUFOTJPO͕ىಈ

  11. 6//PUJpDBUJPO&YUFOTJPO *OJUJBM$POUFOU4J[F3BUJP w ඞਢ w ௨஌7JFXͷΞεϖΫτൺॳظ஋ w 7JFXͷαΠζ͸͋ͱ͔ΒมߋՄೳ w ԣج४

  12. 6//PUJpDBUJPO&YUFOTJPO %FGBVMU$POUFOU)JEEFO w Φϓγϣϯ w σϑΥϧτͷ௨஌಺༰Λදࣔ͢Δ͔Ͳ͏͔ͷϑϥά w 5JUMFɺ4VC5JUMFɺ#PEZͳͲ w σϑΥϧτɿGBMTF

  13. 6//PUJpDBUJPO&YUFOTJPO 0WFSSJEFT%FGBVMU5JUMF w Φϓγϣϯ w ௨஌7JFXͷ্෦λΠτϧΛ7JFX$POUSPMMFSUJUMFͰ ্ॻ͖͢Δ͔Ͳ͏͔ͷϑϥά w ௨஌಺༰ʹ߹ΘͤͨλΠτϧʹ͢Δ͜ͱ΋Մೳ w

    σϑΥϧτɿGBMTF
  14. ࣮૷ // දࣔॲཧͷ࣮ମ // self.title΋͜͜Ͱॻ͖׵͑ΒΕΔ←OverridesDefaultTitle func didReceive(_ notification: UNNotification) {

    } // Actionॲཧͷ࣮ମ func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { } 6//PUJpDBUJPO$POUFOU&YUFOTJPO
  15. ௨஌ͷૹ৴ \ BQT\ BMFSU\ UJUMF5JUMF  TVCUJUMF4VC5JUMF  CPEZ#PEZ ^

     DBUFHPSZNZ$BUFHPSZ ^ ^
  16. ϝϞ w ௨஌7JFX্͸λονΠϕϯτ͕ൃੜ͠ͳ͍ w ϝσΟΞͷ࠶ੜίϯτϩʔϧ͚ͩ͸දࣔ͢ΔͨΊͷ ϓϩύςΟ͕͋Δ w Ϣʔβ͔Βͷૢ࡞Λड͚෇͚͍ͨ৔߹͸ 6//PUJpDBUJPO"DUJPOΛ࢖͏

  17. ϝϞ w /PUJpDBUJPO4FSWJDF&YUFOTJPOͱҧͬͯແࢹͰ͖ ͳ͍ w $BUFHPSZΛΘ͚Δ͜ͱͰෳ਺ͷ&YUFOTJPOΛ࢖͍ ෼͚Δ͜ͱ͕Ͱ͖Δ

  18. ϝϞ w 4FSWJDF&YUFOTJPOͱͷಉډ΋Մೳ NVUBCMFDPOUFOU ແ ༗ DBUFHPSZ ແ  4FSWJDF&YUFOTJPO

    ༗ $POUFOU&YUFOTJPO 4FSWJDF&YUFOTJPO
 ˣ
 $POUFOU&YUFOTJPO
  19. "DUJPOαϯϓϧ \ BQT\ BMFSU\ UJUMFؔϞό  TVCUJUMF  CPEZ/PUJpDBUJPO$POUFOU&YUFOTJPOΛ࢖ͬͯΈͨ!JUPL ^

     DBUFHPSZ,BONPCB  NVUBCMFDPOUFOU  JNHVSMYYY  VSMIUUQTLBONPCBDPOOQBTTDPNFWFOU ^ ^
  20. "DUJPOαϯϓϧ // ϗετΞϓϦέʔγϣϯଆ let action = UNNotificationAction(identifier: "open", title: "Open",

    options: []) let category = UNNotificationCategory(identifier: "Kanmoba", actions: [action], intentIdentifiers: [], options: []) UNUserNotificationCenter.current() .setNotificationCategories([category])
  21. "DUJPOαϯϓϧ // Extensionଆ func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping

    (UNNotificationContentExtensionResponseOption) -> Void) { if response.actionIdentifier == "open" { if let url = response.notification.request.content.userInfo["url"] as? String { self.extensionContext?.open(URL(string: url)!, completionHandler: nil) } } completion(.dismiss) } &YUFOTJPOͰॲཧ͞Εͳ͍ʢϝιου͕ఆٛ͞Ε͍ͯͳ͍ʣ৔߹͸ ϗετʹ౉͞ΕΔʢΒ͍͠ʣ
  22. /PUJpDBUJPO$POUFOU &YUFOTJPOΛ࢖ͬͯ ϦονͳϢʔβମݧΛ