Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
fix: Learners can't sync courses to calendar on iPhone (#1818)
Browse files Browse the repository at this point in the history
  • Loading branch information
shafqat-muneer authored and saeedbashir committed Feb 12, 2024
1 parent 8a78b03 commit 8e37bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Source/CalendarManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> ()) {
Expand Down
2 changes: 2 additions & 0 deletions Source/edX-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@
</dict>
<key>NSCalendarsUsageDescription</key>
<string>edX would like to use your calendar list to subscribe to your personalized edX calendar for this course.</string>
<key>NSCalendarsFullAccessUsageDescription</key>
<string>edX would like to use your calendar list to subscribe to your personalized edX calendar for this course.</string>
<key>NSCameraUsageDescription</key>
<string>so you can take a picture for a profile image</string>
<key>NSContactsUsageDescription</key>
Expand Down

0 comments on commit 8e37bbc

Please sign in to comment.