From 8193655383245f700c89793b8921b43d6d490054 Mon Sep 17 00:00:00 2001 From: Shafqat Muneer Date: Tue, 6 Feb 2024 11:40:26 +0500 Subject: [PATCH] fix: Learners can't sync courses to calendar on iPhone (#1818) --- Source/CalendarManager.swift | 12 +++++++++++- Source/edX-Info.plist | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/CalendarManager.swift b/Source/CalendarManager.swift index 679ac40cf0..587cd59120 100644 --- a/Source/CalendarManager.swift +++ b/Source/CalendarManager.swift @@ -117,13 +117,23 @@ class CalendarManager: NSObject { func requestAccess(completion: @escaping (Bool, EKAuthorizationStatus, EKAuthorizationStatus) -> ()) { let previousStatus = EKEventStore.authorizationStatus(for: .event) - eventStore.requestAccess(to: .event) { [weak self] access, _ in + let requestHandler: (Bool, Error?) -> Void = { [weak self] access, _ in self?.eventStore.reset() let currentStatus = EKEventStore.authorizationStatus(for: .event) DispatchQueue.main.async { completion(access, previousStatus, currentStatus) } } + + if #available(iOS 17.0, *) { + eventStore.requestFullAccessToEvents { access, error in + requestHandler(access, error) + } + } else { + eventStore.requestAccess(to: .event) { access, error in + requestHandler(access, error) + } + } } func addEventsToCalendar(for dateBlocks: [Date : [CourseDateBlock]], completion: @escaping (Bool) -> ()) { diff --git a/Source/edX-Info.plist b/Source/edX-Info.plist index f75ef8d600..b2f4fbc1a2 100644 --- a/Source/edX-Info.plist +++ b/Source/edX-Info.plist @@ -84,6 +84,8 @@ NSCalendarsUsageDescription edX would like to use your calendar list to subscribe to your personalized edX calendar for this course. + NSCalendarsFullAccessUsageDescription + edX would like to use your calendar list to subscribe to your personalized edX calendar for this course. NSCameraUsageDescription so you can take a picture for a profile image NSContactsUsageDescription