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

Advanced Notification for iOS 10

USAMI Kosuke
September 28, 2016

Advanced Notification for iOS 10

USAMI Kosuke

September 28, 2016
Tweet

More Decks by USAMI Kosuke

Other Decks in Programming

Transcript

  1. References ☞ WWDC 2016 ☞ Introduction to Notifications ☞ Advanced

    Notifications ☞ Apple Developer Documentation ☞ UserNotifications ☞ UserNotificationsUI
  2. In-App Presentation (New!) // UNUserNotificationCenterDelegate func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent

    notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { // Show notification in foreground completionHandler([.alert, .sound, .badge]) }
  3. To Display Rich Notification ☞ 3D Touch on Notification ☞

    Swipe Left in Notification List ☞ Swipe Down in Notification Banner
  4. Custom User Interface ☞ Custom Views (No interaction) ☞ Media

    Attachment ☞ Media Playback ☞ Notification Action ☞ Text Input Action
  5. Custom UI ☞ To change layout ... ☞ In Info.plist

    ☞ Specify custom views ratio ☞ Show/Hide default contents
  6. Minimal implementation class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet weak var

    label: UILabel! func didReceive(_ notification: UNNotification) { label.text = notification.request.content.body } }
  7. Media Attachment class NotificationViewController: UIViewController, UNNotificationContentExtension { func didReceive(_ notification:

    UNNotification) { let content = notification.request.content let attachment = content.attachments.first // attachment: UNNotificationAttachment // ... } }
  8. Media Playback ☞ UNNotificationContentExtension ☞ mediaPlayPauseButtonType ☞ none / default

    / overlay ☞ mediaPlayPauseButtonFrame / TintColor ☞ func mediaPlay() / func mediaPause()
  9. Summary ☞ New API ☞ UserNotifications / UserNotificationsUI ☞ Notification

    Service extension ☞ Media Attachments ☞ Notification Content extension ☞ Custom Views / Action