Skip to content

Commit

Permalink
Merge pull request #325 from kvyatkovskys/feature/v_0.6.16
Browse files Browse the repository at this point in the history
use the new method to get access to calendar events
  • Loading branch information
kvyatkovskys authored Sep 11, 2023
2 parents 5c4d8e6 + 2924898 commit cea71e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion KVKCalendar.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KVKCalendar'
s.version = '0.6.15'
s.version = '0.6.16'
s.summary = 'A most fully customization calendar for Apple platforms.'

s.description = <<-DESC
Expand Down
21 changes: 17 additions & 4 deletions Sources/KVKCalendar/KVKCalendarView+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,25 @@ extension KVKCalendarView {
private func requestAccessSystemCalendars(_ calendars: Set<String>,
store: EKEventStore,
completion: @escaping (Bool) -> Void) {
let status = EKEventStore.authorizationStatus(for: .event)

store.requestAccess(to: .event) { (access, error) in
print("System calendars = \(calendars) - access = \(access), error = \(error?.localizedDescription ?? "nil"), status = \(status.rawValue)")
func proxyCompletion(access: Bool, status: EKAuthorizationStatus, error: Error?) {
print("System calendars = \(calendars) - access = \(access), error = \(error?.localizedDescription ?? "nil"), status = \(status)")
completion(access)
}
let status = EKEventStore.authorizationStatus(for: .event)
switch status {
case .fullAccess, .authorized:
completion(true)
default:
if #available(iOS 17.0, *) {
store.requestFullAccessToEvents { (access, error) in
proxyCompletion(access: access, status: status, error: error)
}
} else {
store.requestAccess(to: .event) { (access, error) in
proxyCompletion(access: access, status: status, error: error)
}
}
}
}

private func switchCalendarType(_ type: CalendarType) {
Expand Down

0 comments on commit cea71e0

Please sign in to comment.