EKEventStore+Extensions.swift 843 B

12345678910111213141516171819202122232425262728293031
  1. // LoopFollow
  2. // EKEventStore+Extensions.swift
  3. // Created by Jonas Björkert.
  4. import EventKit
  5. import Foundation
  6. #if swift(>=5.9)
  7. extension EKEventStore {
  8. func requestCalendarAccess(completion: @escaping (Bool, Error?) -> Void) {
  9. if #available(iOS 17, *) {
  10. requestFullAccessToEvents { granted, error in
  11. completion(granted, error)
  12. }
  13. } else {
  14. requestAccess(to: .event) { granted, error in
  15. completion(granted, error)
  16. }
  17. }
  18. }
  19. }
  20. #else
  21. extension EKEventStore {
  22. func requestCalendarAccess(completion: @escaping (Bool, Error?) -> Void) {
  23. requestAccess(to: .event) { granted, error in
  24. completion(granted, error)
  25. }
  26. }
  27. }
  28. #endif