TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

requestFullAccessToEvents is failing

Forums > iOS

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?

3      

I tried changing the bundle ID and it is still retruning with granted false.

3      

OK, so I found it?

With the simulator creating a info record for "Privacy - Calendards Useage Description" is enough, but with a real device you have to define "Privacy - Calendars Full Access Usage Description"

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.