Advanced Notification for iOS 10

0b26590a0a8b0f1da140ed5de9b68379?s=47 USAMI Kosuke
September 28, 2016

Advanced Notification for iOS 10

0b26590a0a8b0f1da140ed5de9b68379?s=128

USAMI Kosuke

September 28, 2016
Tweet

Transcript

  1. Advanced Notification for iOS 10 USAMI Kosuke Fenrir Inc.

  2. iOS Notification API

  3. Old API ☞ UIApplication ☞ Registering for Notifications ☞ UIApplicationDelegate

    ☞ Handling Notifications
  4. New API (iOS 10) ☞ UserNotifications framework ☞ UserNotificationsUI framework

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

    Notifications ☞ Apple Developer Documentation ☞ UserNotifications ☞ UserNotificationsUI
  6. UserNotifications framework

  7. Notification Center ☞ UNUserNotificationCenter

  8. Request User Authorization ☞ UNUserNotificationCenter ☞ func requestAuthorization(_:completionHandler:)

  9. Push Notification ☞ UIApplication ☞ func registerForRemoteNotifications() ☞ (Existing API)

  10. Local Notification ☞ UNUserNotificationCenter ☞ func add(_:withCompletionHandler:) ☞ UNNotificationRequest ☞

    content ☞ trigger : TimeInterval / Calendar / Location
  11. In-App Presentation (New!) // UNUserNotificationCenterDelegate func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent

    notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void) { // Show notification in foreground completionHandler([.alert, .sound, .badge]) }
  12. Others ☞ Custom Action ☞ Notification Management

  13. Advanced Notifications

  14. Advanced Notifications (iOS 10) ☞ Media Attachments ☞ Rich Notification

    (Custom User Interface)
  15. Media Attachments

  16. None
  17. For Local Notification ☞ UNNotificationAttachment ☞ url : URL of

    attachment ☞ type : UTI type
  18. For Push Notification

  19. Notification Service Extension ☞ UserNotifications framework ☞ UNNotificationServiceExtension

  20. Download Attachment ☞ UNNotificationServiceExtension ☞ func didReceive(_:withContentHandler:) ☞ Download in

    Service extension ☞ Create UNNotificationAttachment
  21. Limited Processing Time ☞ UNNotificationServiceExtension ☞ func serviceExtensionTimeWillExpire() ☞ Provide

    some fallback content
  22. Limited File Size ☞ Audio : 5MB ☞ Image :

    10MB ☞ Movie : 50MB
  23. Rich Notification

  24. None
  25. To Display Rich Notification ☞ 3D Touch on Notification ☞

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

    Attachment ☞ Media Playback ☞ Notification Action ☞ Text Input Action
  27. Notification Content Extension ☞ UserNotificationsUI framework ☞ UNNotificationContentExtension

  28. Custom UI ☞ To change layout ... ☞ In Info.plist

    ☞ Specify custom views ratio ☞ Show/Hide default contents
  29. Custom Views ☞ UNNotificationContentExtension ☞ func didReceive(_:) ☞ Get UNNotification

    ☞ Display contents to custom views
  30. Minimal implementation class NotificationViewController: UIViewController, UNNotificationContentExtension { @IBOutlet weak var

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

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

    / overlay ☞ mediaPlayPauseButtonFrame / TintColor ☞ func mediaPlay() / func mediaPause()
  33. Notification Action

  34. Notification Action ☞ UNUserNotificationCenter ☞ Set UNNotificationAction ☞ UNNotificationContentExtension ☞

    func didReceive(_:completionHandler:) ☞ Get UNNotificationResponse
  35. Text Input Action ☞ UNNotificationAction ☞ → UNTextInputNotificationAction ☞ UNNotificationResponse

    ☞ → UNTextInputNotificationResponse
  36. Summary

  37. Summary ☞ New API ☞ UserNotifications / UserNotificationsUI ☞ Notification

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