Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EKEventStore request access not working

var eventStore: EKEventStore?

@IBAction func bbbbbbb(sender: UIButton) {
        if eventStore == nil {
            eventStore = EKEventStore()
        }
        self.eventStore?.requestAccessToEntityType(EKEntityType.Event, completion: { (aBool, error) -> Void in
            print(error, aBool)
        })
}

the print is nil, false always... Its behaving like the user has already denied access, but the promt is never being showed. The same code of course works in a new blank app on the same devices. Things I have tried: resting setting on device, simulator and using a new device where the app has never been installed and of course cleaning the project, but with no success. Plus in the app settings the calendar permission is not showing as well. Any ideas of what is going on?

like image 478
Waylli Avatar asked Aug 05 '26 07:08

Waylli


1 Answers

With iOS 10, you need to add the following key in your plist to allow an app to access the calendar (if not, the app will simply crash when requesting access):

key: "Privacy - Calendars Usage Description"
value: "$(PRODUCT_NAME) calendar events"

see here:

https://iosdevcenters.blogspot.com/2016/09/infoplist-privacy-settings-in-ios-10.html

like image 126
gta8 Avatar answered Aug 07 '26 21:08

gta8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!