Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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. ࣮૷ // දࣔॲཧͷ࣮ମ // self.title΋͜͜Ͱॻ͖׵͑ΒΕΔ←OverridesDefaultTitle func didReceive(_ notification: UNNotification) {

    } // Actionॲཧͷ࣮ମ func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { } 6//PUJpDBUJPO$POUFOU&YUFOTJPO
  2. ϝϞ w 4FSWJDF&YUFOTJPOͱͷಉډ΋Մೳ NVUBCMFDPOUFOU ແ ༗ DBUFHPSZ ແ  4FSWJDF&YUFOTJPO

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

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

    options: []) let category = UNNotificationCategory(identifier: "Kanmoba", actions: [action], intentIdentifiers: [], options: []) UNUserNotificationCenter.current() .setNotificationCategories([category])
  5. "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Ͱॲཧ͞Εͳ͍ʢϝιου͕ఆٛ͞Ε͍ͯͳ͍ʣ৔߹͸ ϗετʹ౉͞ΕΔʢΒ͍͠ʣ