CompletionViewController.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // CompletionViewController.swift
  3. // ResetTransmitter
  4. //
  5. // Copyright © 2018 LoopKit Authors. All rights reserved.
  6. //
  7. import UIKit
  8. import UserNotifications
  9. class CompletionViewController: UITableViewController {
  10. @IBOutlet weak var textView: UITextView!
  11. override func viewDidLoad() {
  12. super.viewDidLoad()
  13. if UIApplication.shared.applicationState == .background {
  14. let content = UNMutableNotificationContent()
  15. content.badge = 1
  16. content.title = NSLocalizedString("Transmitter Reset Complete", comment: "Notification title for background completion notification")
  17. content.body = textView.text
  18. content.sound = .default
  19. let request = UNNotificationRequest(identifier: "Completion", content: content, trigger: nil)
  20. UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
  21. }
  22. }
  23. override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
  24. return false
  25. }
  26. override func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
  27. return nil
  28. }
  29. }