DeviceManager.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // DeviceManager.swift
  3. // LoopKit
  4. //
  5. // Copyright © 2018 LoopKit Authors. All rights reserved.
  6. //
  7. import Foundation
  8. import UserNotifications
  9. public protocol DeviceManagerDelegate {
  10. func scheduleNotification(for manager: DeviceManager,
  11. identifier: String,
  12. content: UNNotificationContent,
  13. trigger: UNNotificationTrigger?)
  14. func clearNotification(for manager: DeviceManager, identifier: String)
  15. }
  16. public protocol DeviceManager: class, CustomDebugStringConvertible {
  17. typealias RawStateValue = [String: Any]
  18. /// The identifier of the manager. This should be unique
  19. static var managerIdentifier: String { get }
  20. /// A title describing this type of manager
  21. static var localizedTitle: String { get }
  22. /// A title describing this manager
  23. var localizedTitle: String { get }
  24. /// The queue on which delegate methods are called
  25. /// Setting to nil resets to a default provided by the manager
  26. var delegateQueue: DispatchQueue! { get set }
  27. /// Initializes the manager with its previously-saved state
  28. ///
  29. /// Return nil if the saved state is invalid to prevent restoration
  30. ///
  31. /// - Parameter rawState: The last state
  32. init?(rawState: RawStateValue)
  33. /// The current, serializable state of the manager
  34. var rawState: RawStateValue { get }
  35. }
  36. public extension DeviceManager {
  37. var localizedTitle: String {
  38. return type(of: self).localizedTitle
  39. }
  40. }