Skip to content

Commit

Permalink
Re-instate support for asking for calendar access on iOS 17
Browse files Browse the repository at this point in the history
The old `requestAccess(to: .event)` immediately errors.
  • Loading branch information
nighthawk committed Nov 24, 2023
1 parent 529ed21 commit 461932e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Sources/TripKit/managers/TKCalendarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ extension TKCalendarManager: TKPermissionManager {
return .notDetermined
case .restricted:
return .restricted
case .denied:
case .denied, .writeOnly:
return .denied
case .authorized:
case .authorized, .fullAccess:
return .authorized
@unknown default:
return .notDetermined
Expand All @@ -87,10 +87,19 @@ extension TKCalendarManager: TKPermissionManager {

public func askForPermission(_ completion: @escaping (Bool) -> Void) {
let oldStore = self.eventStore
oldStore.requestAccess(to: .event) { granted, _ in
self.eventStore = .init()
DispatchQueue.main.async {
completion(granted)
if #available(iOS 17.0, macOS 14.0, *) {
oldStore.requestFullAccessToEvents { granted, _ in
self.eventStore = .init()
DispatchQueue.main.async {
completion(granted)
}
}
} else {
oldStore.requestAccess(to: .event) { granted, _ in
self.eventStore = .init()
DispatchQueue.main.async {
completion(granted)
}
}
}
}
Expand Down

0 comments on commit 461932e

Please sign in to comment.