I'm using requestFullAccessToEvents to get access to my calendar.
Running iPadOS 17.0.1
With the simulator an iPadOS dialog pops up asking permission.
- If I say yes, eveything works. - correct
- If I say no, I don't get acess. - correct
- If I quit and relaunch the app it does not ask again and I don't get acess - correct, but frustrating
- If I delete the app and reinstall it asks me again - correct
- If I say no, I don't get acess. - correct
- If I go into the settings app and scroll all the way to the bottom there is a section Developer and Under that my app.
- I can turn on calendar acess there and then the app getys assess - correct
Now, I try this on a real iPad
- The iPadOS dialog pops up asking permission, but it hidden under my application - wrong
- If I quite my application I can see the dialog.
- I clicked "No"
- I launch my app and I don't get acess. - correct
- I Deelte the app and reinstall it. It does not ask me again and I don't get acess - wrong
- I go into the settings app...
- There is still a developer item, but it before all the applications - ?
- There is no item for my app so I can't change the permissions - wrong.
So there are three differences between the simulator and the real app.
- How the dialog pops up
- Deleting the app is not getting rid of everything
- App not showing up in Settings
I added one item to the Info
Privacy - Calendards Useage Description
The code is pretty simple
class CalendarManager {
private let eventStore = EKEventStore()
var vm: ViewModel?
func requestCalendarAccess(theVM:ViewModel) {
vm = theVM
eventStore.requestFullAccessToEvents { (granted, error) in
DispatchQueue.main.async {
if let error = error {
print("Error requesting calendar access: \(error.localizedDescription)")
return
}
if granted {
if let vm = self.vm
{
vm.canAccessCalendar = true
print("Access granted, proceed to access the calendar")
}
} else {
print("Handle the case where permission was denied")
}
}
}
}
func fetchEvents(startDate: Date, endDate: Date) -> [EKEvent]? {
let predicate = eventStore.predicateForEvents(withStart: startDate, end: endDate, calendars: nil)
return eventStore.events(matching: predicate)
}
}
Any Ideas?